diff --git a/tests/functional/builtins/codegen/test_raw_call.py b/tests/functional/builtins/codegen/test_raw_call.py index 4d37176cf8..b75b5da89b 100644 --- a/tests/functional/builtins/codegen/test_raw_call.py +++ b/tests/functional/builtins/codegen/test_raw_call.py @@ -608,6 +608,22 @@ def foo(_addr: address): ( """ @external +def foo(_addr: address): + raw_call(_addr, method_id("foo()"), is_delegate_call=True, value=1) + """, + ArgumentException, + ), + ( + """ +@external +def foo(_addr: address): + raw_call(_addr, method_id("foo()"), is_static_call=True, value=1) + """, + ArgumentException, + ), + ( + """ +@external @view def foo(_addr: address): raw_call(_addr, 256) diff --git a/vyper/builtins/functions.py b/vyper/builtins/functions.py index 8ee6f5fd76..50ab4dacd8 100644 --- a/vyper/builtins/functions.py +++ b/vyper/builtins/functions.py @@ -1114,13 +1114,16 @@ def build_IR(self, expr, args, kwargs, context): if delegate_call and static_call: raise ArgumentException( - "Call may use one of `is_delegate_call` or `is_static_call`, not both", expr + "Call may use one of `is_delegate_call` or `is_static_call`, not both" ) + + if (delegate_call or static_call) and value.value != 0: + raise ArgumentException("value= may not be passed for static or delegate calls!") + if not static_call and context.is_constant(): raise StateAccessViolation( f"Cannot make modifying calls from {context.pp_constancy()}," - " use `is_static_call=True` to perform this action", - expr, + " use `is_static_call=True` to perform this action" ) if data.value == "~calldata":