]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/gc: restore detail in plain syntax errors
authorRuss Cox <rsc@golang.org>
Tue, 24 Feb 2015 15:21:14 +0000 (10:21 -0500)
committerRuss Cox <rsc@golang.org>
Thu, 26 Feb 2015 17:35:32 +0000 (17:35 +0000)
Change-Id: Ifc4b25fa57d0c9242968246d2193aa29f6b87700
Reviewed-on: https://go-review.googlesource.com/5950
Reviewed-by: Austin Clements <austin@google.com>
src/cmd/internal/gc/subr.go

index b970f1d21a26d38742948728853129b1fc5934df..998b3e7ebf665e286ebded90818fdc8d54f24fbb 100644 (file)
@@ -127,8 +127,12 @@ var yychar_subr int
 var yyerror_lastsyntax int
 
 func Yyerror(fmt_ string, args ...interface{}) {
+       // bison used to invoke yyerror("syntax error").
+       // With Go yacc we get yyerror("%s", "syntax error").
+       // Convert to keep the old code working.
        if fmt_ == "%s" && len(args) == 1 && args[0] == "syntax error" {
-               nsyntaxerrors++
+               fmt_ = "syntax error"
+               args = nil
        }
        if strings.HasPrefix(fmt_, "syntax error") {
                nsyntaxerrors++