cmd/compile: improved error message when calling a shadowed builtin

Otherwise, the error can be confusing if one forgets or doesn't know
that the builtin is being shadowed, which is not common practice.

Fixes #22822.

Change-Id: I735393b5ce28cb83815a1c3f7cd2e7bb5080a32d
Reviewed-on: https://go-review.googlesource.com/97455
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Daniel Martí 2018-02-27 18:54:50 +00:00
parent 4b1d704d14
commit 1e308fbc1a
3 changed files with 36 additions and 1 deletions

View file

@ -65,6 +65,17 @@ var builtinFuncs = [...]struct {
{"recover", ORECOVER},
}
// isBuiltinFuncName reports whether name matches a builtin function
// name.
func isBuiltinFuncName(name string) bool {
for _, fn := range builtinFuncs {
if fn.name == name {
return true
}
}
return false
}
var unsafeFuncs = [...]struct {
name string
op Op