-
Notifications
You must be signed in to change notification settings - Fork 18k
reflect: Append is inconsistent with the builtin append #39359
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
To what capacity appends grow slices is not defined in the language spec and could even change from release to release. Therefore its good to not depend on the actual implementation of how much they grow. Is there a specific reason why they should be kept consistent? That said I wouldnt be surprised if some tests/code breaks having made assumptions as how far |
I agree that it is not a bug. The weak reason to keep them consistent is reflection should try to be consistent with non-reflection. Is it possible that reflection also could call the runtime slice-grow implementation? |
Something like this happens in a couple places, not just with reflect. For example:
Produces:
Because one is a stack allocation and one is a heap allocation. I don't think there's any value in being consistent. At least, there is value in intentionally allowing ourselves to be inconsistent. |
Yes, I agree it is not a big problem, or even a problem. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
What did you expect to see?
Consistent results.
What did you see instead?
Inconsistent results.
Not a big problem. But it would be better if they are consistent.
The text was updated successfully, but these errors were encountered: