Skip to content

Report proper error for named arguments in string/bytes.concat()#16573

Open
tavian-dev wants to merge 1 commit intoargotorg:developfrom
tavian-dev:fix-string-concat-named-args-ice
Open

Report proper error for named arguments in string/bytes.concat()#16573
tavian-dev wants to merge 1 commit intoargotorg:developfrom
tavian-dev:fix-string-concat-named-args-ice

Conversation

@tavian-dev
Copy link
Copy Markdown

Description

Fixes #15735.

Using named arguments with string.concat() or bytes.concat() previously triggered an internal compiler error (ICE) due to a solAssert(_functionCall.names().empty()) assertion. This replaces the assertions with proper TypeError diagnostics so the user gets a clear error message instead of a crash.

Reproduction (from the issue)

contract C {
    function f() public {
        string.concat({x: .3, y: "abc", z: true});
    }
}

Before: Internal compiler error: Solidity assertion failed at TypeChecker.cpp
After: TypeError: Named arguments cannot be used with string.concat().

The same fix is applied to bytes.concat() which had the identical assertion.

Changes

  • libsolidity/analysis/TypeChecker.cpp: Replace solAssert with typeError + return in both typeCheckStringConcatFunction (error 4903) and typeCheckBytesConcatFunction (error 8145)
  • Add syntax tests: string_concat_named_args.sol and bytes_concat_named_args.sol

Testing

  • Built and ran syntax tests (3553 pass, including 2 new tests)
  • Built and ran semantic tests (1636 pass)
  • Verified the exact reproduction case from the issue produces a clean error instead of an ICE
  • Code style check passes

Previously, using named arguments with string.concat() or
bytes.concat() triggered an internal compiler error (ICE) via
solAssert. This replaces the assertions with proper TypeError
diagnostics (4903 for string.concat, 8145 for bytes.concat).

Fixes argotorg#15735
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

Thank you for your contribution to the Solidity compiler! A team member will follow up shortly.

If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother.

If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix.

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.

Named arguments in string.concat() trigger an ICE

1 participant