-
Notifications
You must be signed in to change notification settings - Fork 579
Fix multiple issues uncovered by test suites #641
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
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
99c2b90
Fix printing of empty enum types
ahejlsberg f50647c
Properly format dotted names in diagnostic merging
ahejlsberg ab7f1a3
Accept new baselines
ahejlsberg bace2c3
Don't elaborate on type parameter mismatch errors
ahejlsberg 2257787
Accept new baselines
ahejlsberg 37ed8d5
Implicit export modifier for nested namespaces
ahejlsberg 7bb923b
Accept new baselines
ahejlsberg 0b454ca
Print fully qualified type names when requested
ahejlsberg 0af89df
Accept new baselines
ahejlsberg 3af9692
Fix constructor accessibility check
ahejlsberg 7d62932
Accept new baselines
ahejlsberg b88efa3
Properly initialize Binder.inStrictMode
ahejlsberg 8ce047d
Accept new baselines
ahejlsberg 3025be2
Fix typo in checkPropertyAccessExpressionOrQualifiedName
ahejlsberg 2508f30
Accept new baselines
ahejlsberg 61b57a9
Remove errant quotes
ahejlsberg f683251
Accept new baselines
ahejlsberg fd94aad
Print qualified name with typeof when requested
ahejlsberg 5c81e82
Accept new baselines
ahejlsberg bcbbf56
Port misspelled keyword suggestion logic
ahejlsberg 789c09a
Accept new baselines
ahejlsberg 85def79
Fix property grammar check
ahejlsberg 86baaa6
Accept new baselines
ahejlsberg 81d15cc
Fix fresh type of computed enum types
ahejlsberg 18e8063
Accept new baselines
ahejlsberg e46218c
Check enum members + fix overshift warning
ahejlsberg f3af365
Accept new baselines
ahejlsberg dbcf8cd
Simple free list for Relater objects
ahejlsberg f6c028a
Accept new baselines
ahejlsberg e8f7945
Merge branch 'main' into more-types-37
ahejlsberg ff5ab09
Accept new baselines
ahejlsberg aecd11d
Use Number.Remainder and fix issue in that function
ahejlsberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -365,10 +365,12 @@ func (c *Checker) checkTypeRelatedToEx( | |
headMessage *diagnostics.Message, | ||
diagnosticOutput *[]*ast.Diagnostic, | ||
) bool { | ||
relaterCount := len(c.relaters) | ||
c.relaters = slices.Grow(c.relaters, 1)[:relaterCount+1] | ||
r := &c.relaters[relaterCount] | ||
r.c = c | ||
r := c.freeRelater | ||
if r == nil { | ||
r = &Relater{c: c} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Honestly I feel like we should probably clean this up into a plain sync pool, but, not in this PR. |
||
} else { | ||
c.freeRelater = r.next | ||
} | ||
r.relation = relation | ||
r.errorNode = errorNode | ||
r.relationCount = (16_000_000 - relation.size()) / 8 | ||
|
@@ -396,14 +398,16 @@ func (c *Checker) checkTypeRelatedToEx( | |
} | ||
c.reportDiagnostic(createDiagnosticChainFromErrorChain(r.errorChain, r.errorNode, r.relatedInfo), diagnosticOutput) | ||
} | ||
c.relaters = c.relaters[:relaterCount] | ||
r.maybeKeysSet.Clear() | ||
*r = Relater{ | ||
c: c, | ||
maybeKeys: r.maybeKeys[:0], | ||
maybeKeysSet: r.maybeKeysSet, | ||
sourceStack: r.sourceStack[:0], | ||
targetStack: r.targetStack[:0], | ||
next: c.freeRelater, | ||
} | ||
c.freeRelater = r | ||
return result != TernaryFalse | ||
} | ||
|
||
|
@@ -2521,6 +2525,7 @@ type Relater struct { | |
expandingFlags ExpandingFlags | ||
overflow bool | ||
relationCount int | ||
next *Relater | ||
} | ||
|
||
func (r *Relater) isRelatedToSimple(source *Type, target *Type) Ternary { | ||
|
@@ -4265,18 +4270,20 @@ func (r *Relater) reportUnmatchedProperty(source *Type, target *Type, unmatchedP | |
} | ||
props := r.c.getUnmatchedProperties(source, target, requireOptionalProperties, false /*matchDiscriminantProperties*/) | ||
if len(props) == 1 { | ||
sourceType, targetType := r.c.getTypeNamesForErrorDisplay(source, target) | ||
propName := r.c.symbolToString(unmatchedProperty) | ||
r.reportError(diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName, r.c.TypeToString(source), r.c.TypeToString(target)) | ||
r.reportError(diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName, sourceType, targetType) | ||
if len(unmatchedProperty.Declarations) != 0 { | ||
r.relatedInfo = append(r.relatedInfo, createDiagnosticForNode(unmatchedProperty.Declarations[0], diagnostics.X_0_is_declared_here, propName)) | ||
} | ||
} else if r.tryElaborateArrayLikeErrors(source, target, false /*reportErrors*/) { | ||
sourceType, targetType := r.c.getTypeNamesForErrorDisplay(source, target) | ||
if len(props) > 5 { | ||
propNames := strings.Join(core.Map(props[:4], r.c.symbolToString), ", ") | ||
r.reportError(diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more, r.c.TypeToString(source), r.c.TypeToString(target), propNames, len(props)-4) | ||
r.reportError(diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2_and_3_more, sourceType, targetType, propNames, len(props)-4) | ||
} else { | ||
propNames := strings.Join(core.Map(props, r.c.symbolToString), ", ") | ||
r.reportError(diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, r.c.TypeToString(source), r.c.TypeToString(target), propNames) | ||
r.reportError(diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, sourceType, targetType, propNames) | ||
} | ||
} | ||
} | ||
|
@@ -4677,6 +4684,7 @@ func (r *Relater) reportRelationError(message *diagnostics.Message, source *Type | |
case constraint != nil && r.c.isTypeAssignableTo(source, constraint): | ||
r.reportError(diagnostics.X_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, sourceType, targetType, r.c.TypeToString(constraint)) | ||
default: | ||
r.errorChain = nil // Only report this error once | ||
r.reportError(diagnostics.X_0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1, targetType, generalizedSourceType) | ||
} | ||
} | ||
|
@@ -4755,12 +4763,7 @@ func (r *Relater) reportError(message *diagnostics.Message, args ...any) { | |
diagnostics.The_types_returned_by_0_are_incompatible_between_these_types: | ||
head := getPropertyNameArg(args[0]) | ||
tail := getPropertyNameArg(r.errorChain.next.args[0]) | ||
var arg string | ||
if len(tail) != 0 && tail[0] == '[' { | ||
arg = head + tail | ||
} else { | ||
arg = head + "." + tail | ||
} | ||
arg := addToDottedName(head, tail) | ||
r.errorChain = r.errorChain.next.next | ||
if message == diagnostics.Types_of_property_0_are_incompatible { | ||
message = diagnostics.The_types_of_0_are_incompatible_between_these_types | ||
|
@@ -4772,6 +4775,28 @@ func (r *Relater) reportError(message *diagnostics.Message, args ...any) { | |
r.errorChain = &ErrorChain{next: r.errorChain, message: message, args: args} | ||
} | ||
|
||
func addToDottedName(head string, tail string) string { | ||
if strings.HasPrefix(head, "new ") { | ||
head = "(" + head + ")" | ||
} | ||
pos := 0 | ||
for { | ||
if strings.HasPrefix(tail[pos:], "(") { | ||
pos++ | ||
} else if strings.HasPrefix(tail[pos:], "new ") { | ||
pos += 4 | ||
} else { | ||
break | ||
} | ||
} | ||
prefix := tail[:pos] | ||
suffix := tail[pos:] | ||
if strings.HasPrefix(suffix, "[") { | ||
return prefix + head + suffix | ||
} | ||
return prefix + head + "." + suffix | ||
} | ||
|
||
func (r *Relater) getChainMessage(index int) *diagnostics.Message { | ||
e := r.errorChain | ||
for { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Probably just
numValue.Remainder(32)
? I'd rather not rely on themath
package outside ofjsnum
; I eliminated it everywhere except for the max int consts.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.
Yes, I'll switch to
Number.Remainder
. Which by the way has a bug in it that I'll also fix.