add struct defs to file scope

pull/2099/head
alpharush 1 year ago
parent c21798021c
commit e80238d8e9
  1. 2
      slither/vyper_parsing/declarations/contract.py
  2. 3
      slither/vyper_parsing/type_parsing.py
  3. 4
      tests/e2e/vyper_parsing/snapshots/ast_parsing__vyper_cfgir_interface_constant_slitherConstructorConstantVariables__0.txt
  4. 15
      tests/e2e/vyper_parsing/test_data/interface_constant.vy

@ -453,6 +453,8 @@ class ContractVyper:
st_parser = StructVyper(st, struct)
self._contract.structures_as_dict[st.name] = st
self._structures_parser.append(st_parser)
# Interfaces can refer to struct defs
self._contract.file_scope.structures[st.name] = st
self._structuresNotParsed = []

@ -96,4 +96,7 @@ def parse_type(
if name in contract.file_scope.contracts:
return UserDefinedType(contract.file_scope.contracts[name])
if name in contract.file_scope.structures:
return UserDefinedType(contract.file_scope.structures[name])
assert False

@ -2,8 +2,8 @@ digraph{
0[label="Node Type: OTHER_ENTRYPOINT 0
EXPRESSION:
MAX_TICKS_UINT = 50
MY_CONSTANT = 50
IRs:
MAX_TICKS_UINT(uint256) := 50(uint256)"];
MY_CONSTANT(uint256) := 50(uint256)"];
}

@ -1,12 +1,7 @@
interface LMGauge:
def callback_collateral_shares(n: int256, collateral_per_share: DynArray[uint256, MAX_TICKS_UINT]): nonpayable
def callback_user_shares(user: address, n: int256, user_shares: DynArray[uint256, MAX_TICKS_UINT]): nonpayable
struct MyStruct:
liquidation_range: address
MY_CONSTANT: constant(uint256) = 50
interface MyInterface:
def my_func(a: int256, b: DynArray[uint256, MY_CONSTANT]) -> MyStruct: nonpayable
MAX_TICKS_UINT: constant(uint256) = 50
struct Loan:
liquidation_range: LMGauge
x: public(Loan)
Loading…
Cancel
Save