ng icon indicating copy to clipboard operation
ng copied to clipboard

typecheck: do not allow redeclaration of exported values

Open crawshaw opened this issue 8 years ago • 1 comments

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.

crawshaw avatar Nov 23 '17 20:11 crawshaw

Another method for shadowing exports:

type A struct{}
type A int

crawshaw avatar Nov 25 '17 15:11 crawshaw