From 57cbafa51dd87190e2eec16e150a631c5bae69e7 Mon Sep 17 00:00:00 2001 From: alpharush <0xalpharush@protonmail.com> Date: Wed, 6 Jul 2022 18:20:32 -0500 Subject: [PATCH] handle constant conversionn of type alias --- slither/slithir/convert.py | 5 ++++- .../{constant.sol => constant-0.8.9.sol} | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) rename tests/ast-parsing/user_defined_value_type/{constant.sol => constant-0.8.9.sol} (88%) diff --git a/slither/slithir/convert.py b/slither/slithir/convert.py index 2d5f7ad35..0e2311f69 100644 --- a/slither/slithir/convert.py +++ b/slither/slithir/convert.py @@ -1667,7 +1667,10 @@ def convert_constant_types(irs): if isinstance(ir.rvalue, TupleVariable): # TODO: fix missing Unpack conversion continue - if ir.rvalue.type.type not in ElementaryTypeInt: + if isinstance(ir.rvalue.type, TypeAlias): + ir.rvalue.set_type(ElementaryType(ir.lvalue.type.name)) + was_changed = True + elif ir.rvalue.type.type not in ElementaryTypeInt: ir.rvalue.set_type(ElementaryType(ir.lvalue.type.type)) was_changed = True if isinstance(ir, Binary): diff --git a/tests/ast-parsing/user_defined_value_type/constant.sol b/tests/ast-parsing/user_defined_value_type/constant-0.8.9.sol similarity index 88% rename from tests/ast-parsing/user_defined_value_type/constant.sol rename to tests/ast-parsing/user_defined_value_type/constant-0.8.9.sol index 0cab2a6f3..70b395441 100644 --- a/tests/ast-parsing/user_defined_value_type/constant.sol +++ b/tests/ast-parsing/user_defined_value_type/constant-0.8.9.sol @@ -1,5 +1,5 @@ type T is int224; -pragma solidity >= 0.8.12; +pragma solidity ^0.8.9; contract C { T constant public s = T.wrap(int224(165521356710917456517261742455526507355687727119203895813322792776)); T constant public t = s;