Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec: mentions the term "shadowed" even though it is not defined #56007

Open
mvdan opened this issue Oct 3, 2022 · 4 comments
Open

spec: mentions the term "shadowed" even though it is not defined #56007

mvdan opened this issue Oct 3, 2022 · 4 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mvdan
Copy link
Member

mvdan commented Oct 3, 2022

The spec currently contains this example:

func f(n int) (res int, err error) {
	if _, err := f(n-1); err != nil {
		return  // invalid return statement: err is shadowed
	}
	return
}

However, nowhere else in the entire document does the string "shadow" appear. I know what shadowing means in the context of Go scopes, but the term is not defined in the spec.

The spec does contain this paragraph:

An identifier declared in a block may be redeclared in an inner block. While the identifier of the inner declaration is in scope, it denotes the entity declared by the inner declaration.

I think we should amend it to also define "shadowing". It is already Go terminology, so I think it would be best to canonically define it. If you google "Go shadowing", you get a lot of third-party definitions, almost none of which point to the spec.

cc @griesemer

@mvdan
Copy link
Member Author

mvdan commented Oct 3, 2022

An alternative would be to avoid using the term "shadow" anywhere in the spec, but it is already widely used and understood, so my opinion is that we should define it.

@go101

This comment was marked as off-topic.

@mvdan

This comment was marked as off-topic.

@go101

This comment was marked as off-topic.

@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 6, 2022
@cagedmantis cagedmantis added this to the Backlog milestone Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants