Allow UserDefinedValueType.uwrap (and wrap) as RHS of constant decl

Needed to make `MyType.unwrap` and `MyType.unwrap` as pure in the process. This change affected some
existing tests ("statement has no effect").
This commit is contained in:
hrkrshnn
2021-09-13 11:53:05 +02:00
parent dea1b9ec79
commit a1d4d0125d
6 changed files with 33 additions and 2 deletions
+4 -1
View File
@@ -2916,7 +2916,10 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
// TODO some members might be pure, but for example `address(0x123).balance` is not pure
// although every subexpression is, so leaving this limited for now.
if (auto tt = dynamic_cast<TypeType const*>(exprType))
if (tt->actualType()->category() == Type::Category::Enum)
if (
tt->actualType()->category() == Type::Category::Enum ||
tt->actualType()->category() == Type::Category::UserDefinedValueType
)
annotation.isPure = true;
if (
auto const* functionType = dynamic_cast<FunctionType const*>(exprType);
+3 -1
View File
@@ -3499,7 +3499,9 @@ bool FunctionType::isPure() const
m_kind == Kind::ABIEncodeWithSelector ||
m_kind == Kind::ABIEncodeWithSignature ||
m_kind == Kind::ABIDecode ||
m_kind == Kind::MetaType;
m_kind == Kind::MetaType ||
m_kind == Kind::Wrap ||
m_kind == Kind::Unwrap;
}
TypePointers FunctionType::parseElementaryTypeVector(strings const& _types)