Skip to content

Conversation

@rodiazet
Copy link
Collaborator

Initially reviewed here #16335

This PR fixes assignment to a constant variable of a result of string or bytes concatenation, if their arguments are values known in the compile-time.
Closes: #16188

Additionally

  • Add unit tests
  • Update the Changelog.md
  • Update existing unit tests:
    • Modify tests, which trigger "no-effect" expression warning to silence the warning.
    • Update error message, because now they fail in different (but very similar) way.
    • Add more tests to cover all the builtins

@rodiazet rodiazet changed the title Fix string bytes concat assigment Fix string.concat and bytes.concat assignment to a constant variable. Dec 10, 2025
@rodiazet rodiazet requested a review from cameel December 10, 2025 10:50
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type_information_pure_assignment_error.sol

I don't see any errors in this file :)

}

contract A {
bytes constant aName = type(A).creationCode;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about runtimeCode?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

math_functions_pure_assignment_error.sol

Well, if you exclude keccak, the main common thing between them is that they are wrappers over precompiles. And due to this they might behave differently in some aspects so I'd test them as that and do keccak separately.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also have sha() there twice.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should cover also the block/tx/msg properties.

And global functions like blockhash()/blockhash().

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bytes.concat cannot be used for initializating constant

3 participants