Skip to content

Commit

Permalink
cmd/yacc: fix default action
Browse files Browse the repository at this point in the history
Previously, a production rule like

	A: B C D

would cause yacc to check that A and B have the same declared types,
but then it would generate an implicit action of { $$ = $3 } (i.e.,
copy the value from D), even if A and D have different types.

Fixes golang#10192.

Change-Id: I51cfd7baa0011557141dca33b7af1d892cc6f49e
Reviewed-on: https://go-review.googlesource.com/7780
Reviewed-by: Russ Cox <[email protected]>
  • Loading branch information
mdempsky committed Apr 4, 2015
1 parent 7b850ec commit 2381077
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/cmd/yacc/yacc.go
Original file line number Diff line number Diff line change
Expand Up @@ -637,9 +637,6 @@ outer:
if tempty != nontrst[curprod[0]-NTBASE].value {
lerrorf(ruleline, "default action causes potential type clash")
}
fmt.Fprintf(fcode, "\n\tcase %v:", nprod)
fmt.Fprintf(fcode, "\n\t\t%sVAL.%v = %sS[%spt-0].%v",
prefix, typeset[tempty], prefix, prefix, typeset[tempty])
}
moreprod()
prdptr[nprod] = make([]int, mem)
Expand Down

0 comments on commit 2381077

Please sign in to comment.