ng
ng copied to clipboard
typecheck: do not allow redeclaration of exported values
A problem specific to neugram that Go doesn't run into is that top-level statements of the form
A := 4
declare an exported symbol for use by other packages, and that this can be repeated:
A := 4
A, err := os.Open("file.txt")
This makes it very confusing to find the declared type of an exported symbol. It started off as an int, and ended up an *os.File. I think we should disallow redeclaring exported names. So the second line becomes an error.
Another method for shadowing exports:
type A struct{}
type A int