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
{{ message }}
Repository navigation
Allow declarations with names that collide with primitive types when using @"" syntax #6062
const_=2; // error: `_` is not a declarable symbolconst @"_"=2; // okconstbool=2; // error: variable shadows primitive type 'bool'const @"bool"=2; // ok
It would make sense for them to be distinct since bool is a constant and allowing it to be modified by an alias would result in some really strange behavior.
No. This works because the identifiers using the @"" syntax are actually strings that need to be resolved first. The main difference between the two approaches is that this doesn't make them into keywords. This will be most noticeable in container fields where using bool will remain valid while the other proposal would require using @"bool".
Activity
tadeokondrak commentedon Sep 26, 2020
Would this work?
If not, shadowing a predefined type or identifier would make it impossible to use, since you couldn't even do
since top level decls are order-independent.
Vexu commentedon Sep 26, 2020
It would make sense for them to be distinct since
boolis a constant and allowing it to be modified by an alias would result in some really strange behavior.tadeokondrak commentedon Sep 28, 2020
Wouldn't the only way to implement that be the same as #1802?
Vexu commentedon Sep 30, 2020
No. This works because the identifiers using the
@""syntax are actually strings that need to be resolved first. The main difference between the two approaches is that this doesn't make them into keywords. This will be most noticeable in container fields where usingboolwill remain valid while the other proposal would require using@"bool".andrewrk commentedon Aug 28, 2021
cc @ehaas - I believe some things you were doing were blocking on this.