Type Checker: skip zero-param bindings in operatorDefinitions matching scan#16724
Open
genisis0x wants to merge 1 commit into
Open
Type Checker: skip zero-param bindings in operatorDefinitions matching scan#16724genisis0x wants to merge 1 commit into
genisis0x wants to merge 1 commit into
Conversation
…g scan When a using-for directive contains both a valid operator binding (e.g. `f as -`, two parameters) and a zero-parameter binding (e.g. `g as -`), TypeChecker::endVisit(UsingForDirective) reports the per-binding fatal error 4731 for the zero-parameter function, but only after the matching binding has already triggered the cross-binding scan in Type::operatorDefinitions(). That scan asserted on `!functionType->parameterTypes().empty()` and aborted with an internal compiler error before the user-visible 4731 was emitted. Skip such entries explicitly inside operatorDefinitions(); the TypeChecker still reports the visibility error from the offending binding itself, and the matching scan no longer reaches the assertion. Fixes argotorg#16613
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.
Description
Fixes #16613.
In a global
using { ..., g as <op> } for Tdirective that mixes a valid binding (f as -, two parameters ofT) with a zero-parameter binding (g as -),solc --binpanics with an internal compiler error before the user-visible 4731 (The function "g" does not have any parameters...) is emitted:TypeChecker::endVisit(UsingForDirective)walks the bindings in order. Forfit reaches the per-binding cross-scan atlibsolidity/analysis/TypeChecker.cpp:4224and callsType::operatorDefinitions(_token, _scope, _unary). That helper iterates every binding of every using-for directive onT(includingg), and asserted on!functionType->parameterTypes().empty(). The fatal 4731 forgis only fired later, when the outer loop reaches it.This change keeps the assertion that the binding still maps to a
FunctionType, but treats the empty-parameter case as a no-op for the matching scan. The TypeChecker still emits 4731 fromendVisit(UsingForDirective), so the user-visible diagnostic is unchanged for the well-typed binding paths and for the standalone zero-parameter case (operator_taking_no_parameters_unary.solis unaffected).Tests
test/libsolidity/syntaxTests/operators/userDefined/operator_zero_param_alongside_valid_binding_no_ice.solreproduces the issue MRE (one valid-binding + one zero-parameter-binding) and asserts the expectedTypeError 4731instead of the prior ICE.Checklist
AI Disclosure