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

fix: typechecking of folded builtins #3490

Merged
merged 2 commits into from
Jul 1, 2023

Conversation

trocher
Copy link
Contributor

@trocher trocher commented Jun 28, 2023

What I did

Fix #3486

How I did it

The eval functions of the builtins having integer arguments now expect Int instead of Num.

How to verify it

The following contract now fails to compile with InvalidType instead of a CompilerPanic.

@external
def foo():
    ds:uint256 = uint256_addmod(1.1,2.2,2)

Commit message

fix: typechecking of folded builtins.

Description for the changelog

Prevent decimals from being passed as parameters to builtins expecting integers.

Cute Animal Picture

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

@codecov-commenter
Copy link

codecov-commenter commented Jun 28, 2023

Codecov Report

Merging #3490 (efde32e) into master (c90ab2f) will increase coverage by 0.02%.
The diff coverage is 14.28%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master    #3490      +/-   ##
==========================================
+ Coverage   89.35%   89.37%   +0.02%     
==========================================
  Files          84       84              
  Lines       10777    10780       +3     
  Branches     2456     2457       +1     
==========================================
+ Hits         9630     9635       +5     
+ Misses        751      749       -2     
  Partials      396      396              
Impacted Files Coverage Δ
vyper/builtins/functions.py 90.51% <14.28%> (ø)

... and 8 files with indirect coverage changes

📣 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 good! approved, but i think it would be good to add some unit tests which validate that the correct type of exception is being thrown too before merging.

@trocher
Copy link
Contributor Author

trocher commented Jul 1, 2023

looks good! approved, but i think it would be good to add some unit tests which validate that the correct type of exception is being thrown too before merging.

Only added tests for uint256_addmod and uint256_mulmod as the others concerned builtins are deprecated, should I also do some for them?

@charles-cooper charles-cooper enabled auto-merge (squash) July 1, 2023 20:15
@charles-cooper
Copy link
Member

Only added tests for uint256_addmod and uint256_mulmod as the others concerned builtins are deprecated, should I also do some for them?

no, it looks good. thanks!

@charles-cooper charles-cooper merged commit 29b02dd into vyperlang:master Jul 1, 2023
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.

Compile time evaluation of several builtins wrongfully allows decimal arguments.
3 participants