Skip to content

TypeChecker: skip external free functions in using for resolution#16719

Open
genisis0x wants to merge 1 commit into
argotorg:developfrom
genisis0x:fix/16620-ice-external-free-function-using-for
Open

TypeChecker: skip external free functions in using for resolution#16719
genisis0x wants to merge 1 commit into
argotorg:developfrom
genisis0x:fix/16620-ice-external-free-function-using-for

Conversation

@genisis0x
Copy link
Copy Markdown

Summary

When a free function declared `external` is referenced from a `using for` directive, SyntaxChecker emits error 4126 ("Free functions cannot have visibility.") but the error is not fatal, so type checking continues into `endVisit(UsingForDirective)`. The resolution there calls `FunctionDefinition::type()` on the non-library branch, which asserts `visibility() != External` and triggers an ICE.

Skip such entries explicitly under `solAssert(hasErrors())`. The user still receives the visibility error from the function definition itself, and the directive no longer reaches the assertion.

Fixes #16620

Test plan

  • Added `test/libsolidity/syntaxTests/using/external_free_function.sol` covering the MRE from the issue. Expects the existing SyntaxError 4126 / TypeError 4668 messages and no longer crashes.
  • Full `make test` not run locally (no build environment); relying on CI.

When a free function declared `external` is referenced from a `using for`
directive, SyntaxChecker emits error 4126 ("Free functions cannot have
visibility.") but the error is not fatal, so type checking continues into
endVisit(UsingForDirective). The resolution there calls
`FunctionDefinition::type()` for the non-library branch, which asserts
`visibility() != External` and triggers an ICE.

Skip such entries explicitly under `solAssert(hasErrors())`. The user
still receives the visibility error from the function definition itself,
and the directive no longer reaches the assertion.

Fixes argotorg#16620
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE in FunctionDefinition::type when an external free function is bound via using for

1 participant