From f716c5c5bb814090503eebe15699a3068a55b296 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 24 Feb 2015 10:21:14 -0500 Subject: [PATCH] cmd/internal/gc: restore detail in plain syntax errors Change-Id: Ifc4b25fa57d0c9242968246d2193aa29f6b87700 Reviewed-on: https://go-review.googlesource.com/5950 Reviewed-by: Austin Clements --- src/cmd/internal/gc/subr.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cmd/internal/gc/subr.go b/src/cmd/internal/gc/subr.go index b970f1d21a..998b3e7ebf 100644 --- a/src/cmd/internal/gc/subr.go +++ b/src/cmd/internal/gc/subr.go @@ -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++ -- 2.48.1