mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
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:
@@ -0,0 +1,13 @@
|
||||
type T is int224;
|
||||
pragma solidity >= 0.0.0;
|
||||
contract C {
|
||||
T constant public s = T.wrap(int224(165521356710917456517261742455526507355687727119203895813322792776));
|
||||
T constant public t = s;
|
||||
int224 constant public u = T.unwrap(t);
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// s() -> 165521356710917456517261742455526507355687727119203895813322792776
|
||||
// t() -> 165521356710917456517261742455526507355687727119203895813322792776
|
||||
// u() -> 165521356710917456517261742455526507355687727119203895813322792776
|
||||
@@ -0,0 +1,8 @@
|
||||
contract C {
|
||||
type MyInt is int;
|
||||
MyInt constant mi = MyInt.wrap(5);
|
||||
// This is currently unsupported.
|
||||
uint[MyInt.unwrap(mi)] arr;
|
||||
}
|
||||
// ----
|
||||
// TypeError 5462: (122-138): Invalid array length, expected integer literal or constant expression.
|
||||
@@ -6,3 +6,5 @@ function f() pure {
|
||||
MyAddress.wrap(address(5));
|
||||
}
|
||||
// ----
|
||||
// Warning 6133: (73-87): Statement has no effect.
|
||||
// Warning 6133: (93-119): Statement has no effect.
|
||||
|
||||
@@ -7,3 +7,6 @@ function f() pure {
|
||||
MyUInt8.wrap(50);
|
||||
}
|
||||
// ----
|
||||
// Warning 6133: (75-101): Statement has no effect.
|
||||
// Warning 6133: (107-122): Statement has no effect.
|
||||
// Warning 6133: (128-144): Statement has no effect.
|
||||
|
||||
Reference in New Issue
Block a user