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

Lift restriction on calldata variables shadowing storage variables #2226

Merged
merged 2 commits into from
Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions tests/parser/exceptions/test_namespace_collision.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ def foo():
""",
"""
x: int128

@external
def foo(x: int128): pass
""",
"""
x: int128
iamdefinitelyahuman marked this conversation as resolved.
Show resolved Hide resolved
x: int128
""",
"""
Expand Down Expand Up @@ -60,3 +54,25 @@ def foo():
def test_insufficient_arguments(bad_code):
with pytest.raises(NamespaceCollision):
compiler.compile_code(bad_code)


pass_list = [
"""
x: int128

@external
def foo(x: int128): pass
""",
"""
x: int128

@external
def foo():
x: int128 = 1234
""",
]


@pytest.mark.parametrize("code", pass_list)
def test_valid(code):
compiler.compile_code(code)
2 changes: 0 additions & 2 deletions vyper/context/types/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,6 @@ def from_FunctionDef(
)
if arg.arg in arguments:
raise ArgumentException(f"Function contains multiple inputs named {arg.arg}", arg)
if arg.arg in namespace["self"].members:
raise NamespaceCollision("Name shadows an existing storage-scoped value", arg)
if arg.arg in namespace:
raise NamespaceCollision(arg.arg, arg)

Expand Down
8 changes: 0 additions & 8 deletions vyper/parser/function_definitions/parse_external_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ def validate_external_function(
"__init__ function may not have default parameters.", code
)

# Check for duplicate variables with globals
for arg in sig.args:
if arg.name in global_ctx._globals:
raise FunctionDeclarationException(
"Variable name duplicated between " "function arguments and globals: " + arg.name,
code,
)


def parse_external_function(
code: ast.FunctionDef, sig: FunctionSignature, context: Context, is_contract_payable: bool
Expand Down