You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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()
The text was updated successfully, but these errors were encountered:
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 offunc x
, not the function itself (as in&x()
).What did you see instead?
cannot take the address of x()
The text was updated successfully, but these errors were encountered: