-
Notifications
You must be signed in to change notification settings - Fork 940
Fix checks for disallowed property/accessor duplicate declarations #3672
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
Changes from all commits
9704812
32e7dcd
b8a0a55
dee9069
714ae7d
4aeb37c
9b0938e
bc129e1
4afaaa4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -56,7 +56,7 @@ const ( | |||||||||||
| SymbolFlagsBlockScopedVariableExcludes = SymbolFlagsValue | ||||||||||||
|
|
||||||||||||
| SymbolFlagsParameterExcludes = SymbolFlagsValue | ||||||||||||
| SymbolFlagsPropertyExcludes = SymbolFlagsValue & ^SymbolFlagsProperty | ||||||||||||
| SymbolFlagsPropertyExcludes = SymbolFlagsValue & ^(SymbolFlagsProperty | SymbolFlagsAccessor) | ||||||||||||
| SymbolFlagsEnumMemberExcludes = SymbolFlagsValue | SymbolFlagsType | ||||||||||||
| SymbolFlagsFunctionExcludes = SymbolFlagsValue & ^(SymbolFlagsFunction | SymbolFlagsValueModule | SymbolFlagsClass) | ||||||||||||
| SymbolFlagsClassExcludes = (SymbolFlagsValue | SymbolFlagsType) & ^(SymbolFlagsValueModule | SymbolFlagsInterface | SymbolFlagsFunction) // class-interface mergability done in checker.ts | ||||||||||||
|
|
@@ -66,9 +66,9 @@ const ( | |||||||||||
| SymbolFlagsValueModuleExcludes = SymbolFlagsValue & ^(SymbolFlagsFunction | SymbolFlagsClass | SymbolFlagsRegularEnum | SymbolFlagsValueModule) | ||||||||||||
| SymbolFlagsNamespaceModuleExcludes = SymbolFlagsNone | ||||||||||||
| SymbolFlagsMethodExcludes = SymbolFlagsValue & ^SymbolFlagsMethod | ||||||||||||
|
||||||||||||
| SymbolFlagsMethodExcludes = SymbolFlagsValue & ^SymbolFlagsMethod | |
| SymbolFlagsMethodExcludes = SymbolFlagsValue & ^SymbolFlagsMethod | |
| // Binder intentionally allows property+accessor merges by excluding accessors from | |
| // other value declarations but not from properties. The checker later reports duplicate | |
| // or otherwise invalid combinations within the same declaration. |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -665,7 +665,7 @@ func (b *Binder) bind(node *ast.Node) bool { | |||||
| case ast.KindCallSignature, ast.KindConstructSignature, ast.KindIndexSignature: | ||||||
| b.declareSymbolAndAddToSymbolTable(node, ast.SymbolFlagsSignature, ast.SymbolFlagsNone) | ||||||
| case ast.KindMethodDeclaration, ast.KindMethodSignature: | ||||||
| b.bindPropertyOrMethodOrAccessor(node, ast.SymbolFlagsMethod|getOptionalSymbolFlagForNode(node), core.IfElse(ast.IsObjectLiteralMethod(node), ast.SymbolFlagsPropertyExcludes, ast.SymbolFlagsMethodExcludes)) | ||||||
| b.bindPropertyOrMethodOrAccessor(node, ast.SymbolFlagsMethod|getOptionalSymbolFlagForNode(node), core.IfElse(ast.IsObjectLiteralMethod(node), ast.SymbolFlagsValue, ast.SymbolFlagsMethodExcludes)) | ||||||
|
||||||
| b.bindPropertyOrMethodOrAccessor(node, ast.SymbolFlagsMethod|getOptionalSymbolFlagForNode(node), core.IfElse(ast.IsObjectLiteralMethod(node), ast.SymbolFlagsValue, ast.SymbolFlagsMethodExcludes)) | |
| b.bindPropertyOrMethodOrAccessor(node, ast.SymbolFlagsMethod|getOptionalSymbolFlagForNode(node), ast.SymbolFlagsMethodExcludes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests already show the effects of this change (i.e. method names must be unique in object literals).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These exclusion-mask changes are subtle and directly impact binding/merging semantics (especially around property/accessor merging being allowed in the binder and rejected later in the checker). Please add a short comment near these constants explaining the rationale and the intended invariants (e.g., “binder allows property+accessor merge; checker reports duplicates within the same declaration”), so future modifications don’t inadvertently revert the intended behavior.