Skip to content

Address operator does not allow dereferencing result of func #32956

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

Closed
brendensoares opened this issue Jul 5, 2019 · 1 comment
Closed

Address operator does not allow dereferencing result of func #32956

brendensoares opened this issue Jul 5, 2019 · 1 comment

Comments

@brendensoares
Copy link

What version of Go are you using (go version)?

Go Playground running go 1.12.5

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

N/A

What did you do?

https://play.golang.org/p/Z4YESsk6xXJ

What did you expect to see?

For context, see Go's address operator spec.

Referencing the addressable result of a function (e.g. &x()) should work consistently just as the inverse (dereferencing the addressable result of a function e.g. *x()) as well as referencing a composite literal (e.g. &struct{}{}).

This inconsistency results in more verbose code. A local variable must be created to hold the addressable value and then it can be dereferenced.

As with the currently allowed composite literal scenario (e.g. &struct{}{}), parenthesized syntax should be optional because the () operator makes it clear we're referencing the result of func x, not the function itself (as in &x()).

What did you see instead?

cannot take the address of x()

@ALTree
Copy link
Member

ALTree commented Jul 5, 2019

Thank for the request.

This is a dup of #22647, which was closed as a special case of the more general #9097, so I'm closing this thread in favour of the older one.

@ALTree ALTree closed this as completed Jul 5, 2019
@golang golang locked and limited conversation to collaborators Jul 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants