-
Notifications
You must be signed in to change notification settings - Fork 18k
reflect: ArenaNew panic non-pointer type #60528
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
Comments
Thanks. I think the right thing to do in this circumstance is to fix the function itself, since the |
@mknyszek I don't agree. While this code is not covered by the compatibility guarantee, there's no particular reason to change it. I think we should just change the documentation to match the actual behavior. |
@ianlancetaylor Yeah, sure. That's a good point and fine with me. I don't feel strongly either way. |
I also wanted to clarify: the reason I wanted to change the implementation is that this is reflect function is supposed to be a reflection of (ha) However, I still agree that not breaking people unnecessarily (even in a |
I agree with @mknyszek . This reflect function should behave like arena.New. It should be fixed as early as possible before moving from experiment to standard api. Or it will last forever and confuses people continuously. Don't let this inconsistency become a permanent scar. It's better to endure short-term pain than prolonged suffering. |
I don't think the argument that That said, I admit that I found only one call to See also #56234. |
https://github.com/huandu/go-clone/blob/fcc492e9d68d20fe88146b17e8e45b1c9d9e6b8e/generic/arena.go#L62 reflect.New also returns the Value with the Type of PointerTo(typ). It's better to keep the save behavior.
|
I think that that this is worth fixing even if it breaks existing uses. |
Change https://go.dev/cl/501860 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
test.go:
GOEXPERIMENT=arenas go1.20.4 run -a test.go
What did you expect to see?
print
What did you see instead?
panic:
If I change the code to
v := reflect.ArenaNew(a, reflect.TypeOf(&i))
, it will pass.But it conflicts with the comment of reflect.ArenaNew:
The text was updated successfully, but these errors were encountered: