bug: shadowed panic function
The following code is shadowing the builtin panic function.
package test
func main() {}
func panic(s string){}
func foo() int {
panic("GetByIndex asked for invalid index")
}
When you run this code on master it produces the following
achine.RunMain() panic: GetByIndex asked for invalid index
The VM is creating a panic statement, when it shouldn't. Panic statements should only be created when the code makes a call to the builtin panic function.
This is somewhat related to the issue #1091 which #1711 is meant to address. In that case, we don't want to enable shadowing native / builtin types. Perhaps we also don't want to support shadowing builtin functions; it's confusing for anyone reading the code. Maybe @jaekwon can weigh in here.
This is somewhat related to the issue #1091 which #1711 is meant to address. In that case, we don't want to enable shadowing native / builtin types. Perhaps we also don't want to support shadowing builtin functions; it's confusing for anyone reading the code. Maybe @jaekwon can weigh in here.
Shadowing is part of the language, including for builtin types. I also don't like named return types but they exist. I am not sure if it is a good idea to not implement stuff we don't like.
It is weird in a sense where these builtin functions have no special semantics within the language. They are just regular identifiers. Which means you can shadow them just like any other identifier, like a variable. If we do not allow this, then the implementation of the spec of the language won't be consistent.
let's disallow shadowing builtin functions. it is confusing and can be used to introduce vulnerabilities. it is a restriction of the language so it would be forward-proof even if we decide to allow it. any such restrictions that are ambiguous should start off being restrictions, and we can take our time to decide otherwise. but in any case i don't think we should allow them even in the long run. this should be a panic in the preprocessor after it identifies it as a special builtin name.
This won't be allowed on the agreed shadowing rules.