Skip to content
New issue

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

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

Already on GitHub? # to your account

fix[lang]: transitive exports #3888

Merged

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Mar 23, 2024

What I did

fix #3881

How I did it

How to verify it

Commit message

this commit fixes transitive exports, i.e. where `module1` exports
`module2.foo`, but it was previously not exportable from `module1`. this
is because previously exported functions were not added to the
`ModuleT`'s `exposed_functions` list.

a test had previously been written for this case, but it had been marked
xfail since the desired behavior was not clear until user feedback was
received. this commit removes the `xfail` marker from that test case.

Description for the changelog

Cute Animal Picture

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

@codecov-commenter
Copy link

codecov-commenter commented Mar 23, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 86.32%. Comparing base (cedf708) to head (f32e952).

Files Patch % Lines
vyper/semantics/analysis/module.py 0.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3888      +/-   ##
==========================================
- Coverage   86.38%   86.32%   -0.07%     
==========================================
  Files          92       92              
  Lines       14022    14025       +3     
  Branches     3080     3082       +2     
==========================================
- Hits        12113    12107       -6     
- Misses       1482     1490       +8     
- Partials      427      428       +1     

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

@@ -131,9 +128,7 @@ def foo() -> uint256:
assert c.foo() == 5


# not sure if this one should work
Copy link
Collaborator

Choose a reason for hiding this comment

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

For the the future we should track these cases (i.e. ambiguous spec) somewhere properly, since we obviously forgot about it and thanks to feedback rediscovered it.

Nit: if we use xfail, we should also add the reason attribute instead of a comment to be consistent:

Copy link
Member Author

Choose a reason for hiding this comment

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

i don't really get this -- it's easy to grep the codebase or to run with pytest --runxfail. i guess you mean we should be doing this on a regular basis?

Copy link
Collaborator

Choose a reason for hiding this comment

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

it's easy to grep the codebase or to run with pytest --runxfail. i guess you mean we should be doing this on a regular basis?

My point is not that it's easy, but that we forget about certain xfail tests that are part of a bigger features (like in this case) and we forget to address it before the release.

# not sure if this one should work
@pytest.mark.xfail(reason="ambiguous spec")
def test_recursive_export(make_input_bundle, get_contract):
def test_transitive_export(make_input_bundle, get_contract):
lib1 = """
@external
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: this should be @pure

Copy link
Collaborator

Choose a reason for hiding this comment

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

the current test for transitive exports is pretty limited. Is there a smart way, where we can fuzz different nestedness & visibility decorators?

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm i don't think we need to "fuzz" so to speak, and the external/internal distinction should be tested in other tests already. as for nesting, we could maybe set up a chaining test for like 1-5 levels of nesting.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, that sounds reasonable to me.

@charles-cooper charles-cooper merged commit ea7f081 into vyperlang:master Mar 26, 2024
149 checks passed
@charles-cooper charles-cooper deleted the fix/transitive-exports branch March 26, 2024 14:24
electriclilies pushed a commit to electriclilies/vyper that referenced this pull request Apr 27, 2024
this commit fixes transitive exports, i.e. where `module1` exports
`module2.foo`, but it was previously not exportable from `module1`. this
is because previously exported functions were not added to the
`ModuleT`'s `exposed_functions` list.

a test had previously been written for this case, but it had been marked
xfail since the desired behavior was not clear until user feedback was
received. this commit removes the `xfail` marker from that test case.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

transitive exports do not work
5 participants