fix[ux]: improve checksum error messages - #5218
Conversation
|
I'm not sure what is the reason for the new error class, I kept it, but the new raising logic does not depend on it |
Gas ChangesNo changes detected. Summary
|
📊 Bytecode Size Changes (venom)No changes detected. Full bytecode sizes
|
charles-cooper
left a comment
There was a problem hiding this comment.
approved once the helpers are changed to classmethod and that stray AddressT() => AddressT
|
@charles-cooper feel free to merge when CI passes |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ab1482dc2e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| suggestion_str = f" Did you mean {checksum_encode(node.value)}?" | ||
| # call `validate_literal` for its side effect of throwing an exception for | ||
| # address checksum mismatch | ||
| AddressT().validate_literal(node) |
There was a problem hiding this comment.
Preserve checksum errors for conditional address literals
When a lower-case 20-byte address with a bad checksum is used through a conditional expression, e.g. x: address = 0x... if True else 0x..., inference gives the IfExp a bytes20 type and reaches this branch. validate_literal is then called on the IfExp rather than a Hex leaf, so its base validator raises the generic InvalidLiteral: Invalid literal for address; the new BadChecksumAddress and corrective checksum hint are lost. Validate the relevant hex branch(es), or guard this path so non-Hex expressions retain an appropriate checksum diagnostic.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fair, but I think that's something that needs to be fixed with #5017
What I did
Rebase #3621
Fix #3611
Refactor a bit the raising logic to make it nicer, see b19b32e
Closes #3621
How I did it
How to verify it
Run tests, includes new tests
Commit message
Description for the changelog
Improve error messages involving address literals with incorrect checksums
Cute Animal Picture