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: allow accessing members of constant address #3261

Merged
merged 4 commits into from
Jan 31, 2023

Conversation

tserg
Copy link
Collaborator

@tserg tserg commented Jan 28, 2023

What I did

Fix #3258.

How I did it

Remove visit_Hex, which was overriding visit_Constant. This caused the propagated type to be ignored and overriden with the None value.

On an unrelated but similar reasoning, I also removed visit_Int and visit_Bytes.

How to verify it

See tests.

Commit message

fix: allow accessing members of constant address

Description for the changelog

Allow accessing members of constant address

Cute Animal Picture

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

@tserg
Copy link
Collaborator Author

tserg commented Jan 28, 2023

Is this valid syntax? I think it should be, but trying to figure out the required changes to the lark grammar.

@external
def foo() -> uint256:
    x: uint256 = 0x776Ba14735FF84789320718cf0aa43e91F7A8Ce1.balance
    return x

@codecov-commenter
Copy link

codecov-commenter commented Jan 28, 2023

Codecov Report

Merging #3261 (f4cb780) into master (02339df) will decrease coverage by 0.01%.
The diff coverage is n/a.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master    #3261      +/-   ##
==========================================
- Coverage   88.88%   88.87%   -0.01%     
==========================================
  Files          84       84              
  Lines       10598    10592       -6     
  Branches     2212     2212              
==========================================
- Hits         9420     9414       -6     
  Misses        769      769              
  Partials      409      409              
Impacted Files Coverage Δ
vyper/semantics/analysis/annotation.py 89.26% <ø> (-0.36%) ⬇️

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

@fubuloubu
Copy link
Member

Is this valid syntax? I think it should be, but trying to figure out the required changes to the lark grammar.

@external
def foo() -> uint256:
    x: uint256 = 0x776Ba14735FF84789320718cf0aa43e91F7A8Ce1.balance
    return x

Its not currently valid, no. I think it would rare you would need to use it like this, so I have no problem forcing people to do it a different way

@tserg tserg marked this pull request as ready for review January 29, 2023 09:10
@tserg
Copy link
Collaborator Author

tserg commented Jan 30, 2023

Is this valid syntax? I think it should be, but trying to figure out the required changes to the lark grammar.

@external
def foo() -> uint256:
    x: uint256 = 0x776Ba14735FF84789320718cf0aa43e91F7A8Ce1.balance
    return x

Its not currently valid, no. I think it would rare you would need to use it like this, so I have no problem forcing people to do it a different way

This would fail the grammar test, but would actually compile in 0.3.7 and the latest master branch. It is actually similar to this contract after constant folding.

a: constant(address) = 0x776Ba14735FF84789320718cf0aa43e91F7A8Ce1
@external
def foo() -> uint256:
    x: uint256 = a.balance
    return x

@charles-cooper charles-cooper merged commit b5eb5f7 into vyperlang:master Jan 31, 2023
@tserg tserg deleted the fix/constant_address branch January 31, 2023 03:54
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.

TypeCheckFailure when accessing the members of a literal or constant address
4 participants