BREAKING CHANGE: Avoid collisions between static class/namespace members#2804
BREAKING CHANGE: Avoid collisions between static class/namespace members#2804CountBleck wants to merge 1 commit intoAssemblyScript:mainfrom
Conversation
This commit changes the delimiter between namespaces and their members from "." to "::" in internal names. The new delimiter certainly feels very un-JavaScript-y, but the meaning is still recognizable, and these names aren't exposed to users in most cases anyway. Still, this is a breaking change, as it affects the import names for `declare namespace` members (as seen in tests/compiler/declare.js), and transform authors will also need to update their code accordingly. Fixes AssemblyScript#2793.
HerrCai0907
left a comment
There was a problem hiding this comment.
should we do diagnose first before merge this PR?
class NS {
static v: i32 = 2;
}
namespace NS {
export let v: i32 = 1;
}
Actually, this makes me realize how redundant this PR is, since if that diagnostic is emitted, then there wouldn't be a collision. |
|
Never mind, the diagnostic is only needed for exported namespace members. |
|
@MaxGraey If you come up with a better delimiter, let me know. Separately, it looks like TS supports namespaces being redeclared with non-exported members (of different types too), and it's probably easier if AS doesn't support that for now (just from looking at how these declarations are merged). |
|
It looks like supporting this properly is a pain, since modifying @HerrCai0907's example to remove the It's probably best to diagnose this in every case. |
Fixes #2793.
Changes proposed in this pull request:
⯈ Change the delimiter between namespaces and their members from
.to::