mirror of
https://github.com/golang/go
synced 2024-11-05 11:46:12 -07:00
4f2a73011f
This CL extends cmd/yacc to expose a yyErrorVerbose variable that changes the error messages from just "syntax error" to "syntax error: unexpected ${tokname}". It also moves the yyToknames table generation to after rules have been processed so that entries can be generated for tokens that aren't mentioned in the preamble (e.g., '.' in the case of go.y). Lastly, it restores gc's old code for applying yytfix to yyToknames, except that substituting "LLITERAL" with litbuf happens in Yyerror. Fixes #9968. Change-Id: Icec188d11fdabc1dae31b8a471c35b5c7f6deec7 Reviewed-on: https://go-review.googlesource.com/8432 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
40 lines
992 B
Go
40 lines
992 B
Go
// errorcheck
|
|
|
|
// Copyright 2011 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Issue 2231
|
|
|
|
package main
|
|
import "runtime"
|
|
|
|
func foo(runtime.UintType, i int) { // ERROR "cannot declare name runtime.UintType|named/anonymous mix|undefined identifier"
|
|
println(i, runtime.UintType) // GCCGO_ERROR "undefined identifier"
|
|
}
|
|
|
|
func bar(i int) {
|
|
runtime.UintType := i // ERROR "cannot declare name runtime.UintType|non-name on left side|undefined identifier"
|
|
println(runtime.UintType) // GCCGO_ERROR "invalid use of type|undefined identifier"
|
|
}
|
|
|
|
func baz() {
|
|
main.i := 1 // ERROR "non-name main.i|non-name on left side"
|
|
println(main.i) // GCCGO_ERROR "no fields or methods"
|
|
}
|
|
|
|
func qux() {
|
|
var main.i // ERROR "unexpected [.]|expected type"
|
|
println(main.i)
|
|
}
|
|
|
|
func corge() {
|
|
var foo.i int // ERROR "unexpected [.]|expected type"
|
|
println(foo.i)
|
|
}
|
|
|
|
func main() {
|
|
foo(42,43)
|
|
bar(1969)
|
|
}
|