Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve error message for non-checksummed address literal #3065

Merged
merged 8 commits into from
Aug 13, 2022

Conversation

tserg
Copy link
Collaborator

@tserg tserg commented Aug 12, 2022

What I did

QOL improvement for #3062.

When declaring an address literal, the compiler throws an InvalidType exception if it is not checksummed. This PR improves the error message by checking if the user meant the checksummed value.

How I did it

Add an error message if expected type is address and the only possible type is bytes20.

How to verify it

NA

Commit message

chore: improve error message for non-checksummed address literal

Description for the changelog

Improve error message for non-checksummed address literal

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@codecov-commenter
Copy link

codecov-commenter commented Aug 12, 2022

Codecov Report

Merging #3065 (f1e70c6) into master (c71b023) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #3065   +/-   ##
=======================================
  Coverage   88.35%   88.36%           
=======================================
  Files          97       97           
  Lines       10968    10974    +6     
  Branches     2593     2594    +1     
=======================================
+ Hits         9691     9697    +6     
  Misses        827      827           
  Partials      450      450           
Impacted Files Coverage Δ
vyper/semantics/validation/utils.py 91.56% <100.00%> (+0.21%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

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

looks nice, will take a double check of the functionality later and merge if it looks good

Comment on lines 464 to 467
len(expected_type) == 1
and isinstance(expected_type[0], AddressDefinition)
and len(given_types) == 1
and isinstance(given_types[0], Bytes20Definition)
Copy link
Member

Choose a reason for hiding this comment

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

nit -- because of preconditions earlier in this function, we know that both lists are nonzero. i think it's worth it to slightly generalize this check and remove the len() == 1 checks, because it's easier from a maintenance standpoint to constrain the check if it turns out to be wrong than to relax the constraint.

@charles-cooper charles-cooper merged commit d90f540 into vyperlang:master Aug 13, 2022
@tserg tserg deleted the fix/constant_addr branch August 15, 2022 02:16
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.

3 participants