-
Notifications
You must be signed in to change notification settings - Fork 1.7k
No way to create symbol representing private setter name #34904
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
I'm not sure there is a way. Our So, we cannot create a private setter symbol, and currently we cannot create a symbol for We can allow To handle the other cases, we could change the rules so that That would allow all the possible combinations of symbols that are currently being used, except perhaps |
The VM currently doesn't throw in this case, but it also doesn't mangle the symbol either. I think mangling the input to This is not directly related, but in obfuscation, do you think we should obfuscate symbols created via |
We should never mangle for a The only way to make a constant private (mangled) symbol is a symbol literal. (The other ways to create non-constant private symbols are |
Ok, then the original problem remains, because a mangled private symbol is not equal to a non-mangled symbol with the same identifier. The use case is recognizing a private setter within a NSM implementation, for example the test |
@lrhn @leafpetersen @eernstg there are few bugs essentially about the same thing in the tracker. Could language team make a decision about this and deduplicate all bugs into a single place? |
Symbol constructor can't be used to create symbols for private names. Closes #34377 Closes #30848 #36433 #34904 Change-Id: Ibe551c43a9209e1f483cea8178665890d52799aa Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108416 Reviewed-by: Vyacheslav Egorov <[email protected]> Commit-Queue: Vyacheslav Egorov <[email protected]>
Closing this in favor of the language tracking issue here. |
According to the documentation, the constructor for
const Symbol()
does not accept private names. The only other way to construct a constant symbol is via the#...
notation, e.g.#_x
. However, this doesn't work for names of setters, e.g._x=
, because#_x=
isn't syntactically correct.How can the name of a private setter be expressed as a constant symbol?
For reference, I'm updating the
mock_writable_final_private_field_test.dart
which is currently exploiting an incorrect behavior in the VM to do this. The VM currently allows creating a private symbol in this way, but it is not correctly mangled.The text was updated successfully, but these errors were encountered: