Skip to content

Commit

Permalink
chore: add another borrowship test (vyperlang#3802)
Browse files Browse the repository at this point in the history
clarify the behavior of storage access through nested attribute access
  • Loading branch information
charles-cooper authored Feb 22, 2024
1 parent 9a31ee6 commit f8edd29
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion tests/functional/syntax/modules/test_initializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ def foo():
@external
def foo(new_value: uint256):
# can access lib1 state through lib2?
# cannot access lib1 state through lib2, lib2 does not `use` lib1.
lib2.lib1.counter = new_value
"""
input_bundle = make_input_bundle({"lib1.vy": lib1, "lib2.vy": lib2})
Expand All @@ -860,6 +860,35 @@ def foo(new_value: uint256):
assert e.value._hint == expected_hint


def test_uses_skip_import2(make_input_bundle):
lib1 = """
counter: uint256
"""
lib2 = """
import lib1
initializes: lib1
@internal
def foo():
pass
"""
main = """
import lib1
import lib2
initializes: lib2
@external
def foo(new_value: uint256):
# *can* access lib1 state through lib2, because lib2 initializes lib1
lib2.lib1.counter = new_value
"""
input_bundle = make_input_bundle({"lib1.vy": lib1, "lib2.vy": lib2})

assert compile_code(main, input_bundle=input_bundle) is not None


def test_invalid_uses(make_input_bundle, chdir_tmp_path):
lib1 = """
counter: uint256
Expand Down

0 comments on commit f8edd29

Please sign in to comment.