Type Checker: skip zero-param free functions in attachedFunctions resolution#16725
Open
genisis0x wants to merge 1 commit into
Open
Type Checker: skip zero-param free functions in attachedFunctions resolution#16725genisis0x wants to merge 1 commit into
genisis0x wants to merge 1 commit into
Conversation
…olution
When a using-for directive binds a zero-parameter free function and the
call site (`x.zero()`) appears earlier in the contract body than the
directive itself, member resolution runs before TypeChecker visits the
directive. attachedFunctions reaches addFunction(), which calls
FunctionType::withBoundFirstArgument() and asserts on
`!m_parameterTypes.empty()`, triggering an internal compiler error
before the user-visible 4731 ("function does not have any parameters")
is emitted.
Library-bound resolution already filters out zero-parameter functions in
the loop above; mirror the same filter for the non-library branch. The
TypeChecker's endVisit(UsingForDirective) still reports 4731 for the
directive itself, and the call-site separately reports 9582 ("member not
found"). The user-visible diagnostics are unchanged for well-typed code.
Fixes argotorg#16610
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 #16610.
solc --binpanics with an internal compiler error when ausing { zero } for Tdirective binds a zero-parameter free function and the call site (x.zero()) appears in the contract body before the directive:Type::attachedFunctions()is called from member resolution while typecheckingz.zero(). For library-bound entries it already filters out functions with no parameters atTypes.cpp:460, but the non-library branch (free functions bound viausing { zero } for T) callsaddFunction()unconditionally, which asserts inFunctionType::withBoundFirstArgument(). The fatal4731("does not have any parameters") inTypeChecker::endVisit(UsingForDirective)only fires later, when the directive itself is visited.This change mirrors the existing library-binding filter for free-function bindings: empty-parameter entries are skipped during attached-function resolution. The TypeChecker still emits the 4731 error from the directive, and the call site separately emits a
9582"member not found" error, matching the diagnostics surface that users would see for any other unattached function.Tests
test/libsolidity/syntaxTests/using/using_free_no_parameters_call_site_before_directive.solreproduces the issue MRE and asserts both expectedTypeError 9582andTypeError 4731instead of the prior ICE.using_free_no_parameters_err.sol(directive without call site) is unaffected.Checklist
AI Disclosure