TypeChecker: don't ICE when duplicate user-defined operators are reached before the using for check#16720
Open
genisis0x wants to merge 1 commit into
Conversation
…hed before the `using for` check `TypeChecker::visit(UnaryOperation)` and `endVisit(BinaryOperation)` both asserted `m_errorReporter.hasErrors()` when more than one matching user-defined operator definition was found, relying on the duplicate check inside `endVisit(UsingForDirective)` (error 4705) to have already fired. That assumption breaks when a function body references the operator before the directive is fully type-checked — the duplicate is visible via the scope lookup, but no error has been emitted yet, so the assertion triggers an ICE. Drop the assertion. Picking the first match is harmless because the directive's duplicate check still runs and surfaces error 4705 to the user, halting compilation cleanly. Fixes argotorg#16616 Fixes argotorg#16636
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
`TypeChecker::visit(UnaryOperation)` and `endVisit(BinaryOperation)` both asserted `m_errorReporter.hasErrors()` when more than one matching user-defined operator definition was found, relying on the duplicate check inside `endVisit(UsingForDirective)` (error 4705) to have already fired. That assumption breaks when a function body references the operator before the directive is fully type-checked — the duplicate is visible via the scope lookup, but no error has been emitted yet, so the assertion triggers an ICE.
Drop the assertion. Picking the first match is harmless because the directive's duplicate check still runs and surfaces error 4705 to the user, halting compilation cleanly.
Fixes #16616
Fixes #16636
Test plan
TypeChecker::endVisit(BinaryOperation)when duplicateusing foroperator bindings include a self-referential call #16616)TypeChecker::visit(UnaryOperation)when duplicateusing forunary operator bindings include a self-referential call #16636)