cznic / goyacc

github.com/cznic/goyacc has moved to modernc.org/goyacc
https://godoc.org/modernc.org/goyacc
BSD 3-Clause "New" or "Revised" License
208 stars 24 forks source link

Missed typecheck. #16

Closed cznic closed 9 years ago

cznic commented 9 years ago
$ cat bug.y
%union{
    val  int
    vals []int
}

%token  I
%type   <vals>  L

%%

S:  L

L:
    {
        $$ = []int(nil)
    }
|   L I
    {
        $$ = append($$, $2)
    }
$ goyacc -o /dev/stdout bug.y | grep yypt-0
Parse table entries: 5 of 24, x 8 bits == 5 bytes
        yyVAL.vals = append(yyVAL.vals, yyS[yypt-0].)
$ 

Token I should have been declared as %token <val> I, but the missing type of $2 gets undetected by the y package. Goyacc then renders invalid Go code.

cznic commented 9 years ago

Closed by https://github.com/cznic/y/commit/d8d6b6e21858a5f10f716272e7d014190a589dd8