Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/yacc: Empty grammar fails to compile on Go 1.5 #12154

Closed
leocassarani opened this issue Aug 15, 2015 · 2 comments
Closed

cmd/yacc: Empty grammar fails to compile on Go 1.5 #12154

leocassarani opened this issue Aug 15, 2015 · 2 comments
Milestone

Comments

@leocassarani
Copy link

I'm testing go1.5rc1 on linux/amd64, and I've come across an issue that prevents the compilation of an empty yacc grammar.

Steps to reproduce

Create a file named main.y with the following contents:

%{
package main

type yyLex struct{}
func (x *yyLex) Lex(yylval *yySymType) int { return 0 }
func (x *yyLex) Error(str string) {}

func main() {}
%}

%union {
}

%%

top: /* empty grammar */

%%

Run the following commands:

$ go tool yacc -o main.go main.y
$ go build main.go

Expected results

The code should compile without errors.

Actual results

Compilation fails with the error message:

yaccpar:161[main.go:253]: yyDollar declared and not used

Additional information

The compilation error occurs in the Parse(yylex yyLexer) int method on the *yyParserImpl type. Line 253 of the generated main.go file defines a variable var yyDollar []yySymType, which is never referenced by the rest of the auto-generated method.

I've followed the same steps on Go 1.4, and checked that they produce the expected result. In fact, I believe the issue originated with commit 2e78447, which first introduced the yyDollar variable.

@rsc rsc added this to the Go1.5Maybe milestone Aug 16, 2015
@robpike
Copy link
Contributor

robpike commented Aug 17, 2015

Although I understand this broke a test case, is the test case realistic in any meaningful sense?

@gopherbot
Copy link

CL https://golang.org/cl/13673 mentions this issue.

@rsc rsc closed this as completed in 3f01621 Aug 18, 2015
@mikioh mikioh modified the milestones: Go1.5, Go1.5Maybe Aug 18, 2015
@golang golang locked and limited conversation to collaborators Aug 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants