@@ -109,7 +109,7 @@ func (fc *funcContext) translateStmt(stmt ast.Stmt, label *types.Label) {
109109
110110 if label != nil || analysis .HasBreak (clause ) {
111111 if label != nil {
112- fc .Printf ("%s:" , label .Name ())
112+ fc .Printf ("%s:" , sanitizeName ( label .Name () ))
113113 }
114114 fc .Printf ("switch (0) { default:" )
115115 fc .Indented (func () {
@@ -306,7 +306,7 @@ func (fc *funcContext) translateStmt(stmt ast.Stmt, label *types.Label) {
306306 blockingLabel := ""
307307 data := fc .flowDatas [nil ]
308308 if s .Label != nil {
309- normalLabel = " " + s .Label .Name
309+ normalLabel = " " + sanitizeName ( s .Label .Name )
310310 blockingLabel = " s" // use explicit label "s", because surrounding loop may not be flattened
311311 data = fc .flowDatas [fc .pkgCtx .Uses [s .Label ].(* types.Label )]
312312 }
@@ -317,7 +317,7 @@ func (fc *funcContext) translateStmt(stmt ast.Stmt, label *types.Label) {
317317 data .postStmt ()
318318 fc .PrintCond (data .beginCase == 0 , fmt .Sprintf ("continue%s;" , normalLabel ), fmt .Sprintf ("$s = %d; continue%s;" , data .beginCase , blockingLabel ))
319319 case token .GOTO :
320- fc .PrintCond (false , "goto " + s . Label . Name , fmt .Sprintf ("$s = %d; continue;" , fc .labelCase (fc .pkgCtx .Uses [s .Label ].(* types.Label ))))
320+ fc .PrintCond (false , "goto" + normalLabel , fmt .Sprintf ("$s = %d; continue;" , fc .labelCase (fc .pkgCtx .Uses [s .Label ].(* types.Label ))))
321321 case token .FALLTHROUGH :
322322 // handled in CaseClause
323323 default :
@@ -461,7 +461,7 @@ func (fc *funcContext) translateStmt(stmt ast.Stmt, label *types.Label) {
461461 case * ast.LabeledStmt :
462462 label := fc .pkgCtx .Defs [s .Label ].(* types.Label )
463463 if fc .GotoLabel [label ] {
464- fc .PrintCond (false , s .Label .Name + ":" , fmt .Sprintf ("case %d:" , fc .labelCase (label )))
464+ fc .PrintCond (false , sanitizeName ( s .Label .Name ) + ":" , fmt .Sprintf ("case %d:" , fc .labelCase (label )))
465465 }
466466 fc .translateStmt (s .Stmt , label )
467467
@@ -586,7 +586,7 @@ func (fc *funcContext) translateBranchingStmt(caseClauses []*ast.CaseClause, def
586586 }
587587
588588 if label != nil && ! flatten {
589- fc .Printf ("%s:" , label .Name ())
589+ fc .Printf ("%s:" , sanitizeName ( label .Name () ))
590590 }
591591
592592 condStrs := make ([]string , len (caseClauses ))
@@ -652,7 +652,7 @@ func (fc *funcContext) translateLoopingStmt(cond func() string, body *ast.BlockS
652652 }()
653653
654654 if ! flatten && label != nil {
655- fc .Printf ("%s:" , label .Name ())
655+ fc .Printf ("%s:" , sanitizeName ( label .Name () ))
656656 }
657657 isTerminated := false
658658 fc .PrintCond (! flatten , "while (true) {" , fmt .Sprintf ("case %d:" , data .beginCase ))
0 commit comments