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[lang]: fix .vyi function body check #4177

Merged
merged 4 commits into from
Jul 29, 2024

Conversation

cyberthirst
Copy link
Collaborator

@cyberthirst cyberthirst commented Jul 24, 2024

What I did

How to verify it

  • added both a failing and passing tests

commit message

previously the validation for function bodies in interfaces incorrectly
allowed other types of expressions with the `.value` member, e.g.

```vyper
@external
def some_interface_function():
    return ...
```
although the body should only be allowed to be an ellipsis expr (`...`).

this commit correctly rejects the above source code

body = funcdef.body

if len(body) != 1 or not (
isinstance(body[0], vy_ast.Expr) and isinstance(body[0].get("value"), vy_ast.Ellipsis)
Copy link
Member

Choose a reason for hiding this comment

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

once we have refined the type of body[0], we don't need to use get(), we can just directly reference .value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

addressed in: f006571

@cyberthirst cyberthirst added this to the v0.4.1 milestone Jul 26, 2024
Copy link

codecov bot commented Jul 27, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 46.19%. Comparing base (a1af967) to head (f006571).
Report is 1 commits behind head on master.

Files Patch % Lines
vyper/semantics/types/function.py 0.00% 2 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (a1af967) and HEAD (f006571). Click for more details.

HEAD has 139 uploads less than BASE
Flag BASE (a1af967) HEAD (f006571)
140 1
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4177       +/-   ##
===========================================
- Coverage   91.35%   46.19%   -45.16%     
===========================================
  Files         109      109               
  Lines       15613    15614        +1     
  Branches     3436     3436               
===========================================
- Hits        14263     7213     -7050     
- Misses        920     7847     +6927     
- Partials      430      554      +124     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@charles-cooper charles-cooper changed the title fix[lang]: make vyi interface function body check stricter fix[lang]: fix .vyi function body check Jul 29, 2024
@charles-cooper charles-cooper merged commit 99304da into vyperlang:master Jul 29, 2024
157 of 159 checks passed
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.

Un-precise Interface Body Check
2 participants