mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #12094 from ethereum/ice-12066
Fix ICE when printing an error message related to mappings
This commit is contained in:
commit
aed218fd75
@ -11,6 +11,7 @@ Compiler Features:
|
||||
Bugfixes:
|
||||
* Commandline Interface: Fix extra newline character being appended to sources passed through standard input, affecting their hashes.
|
||||
* SMTChecker: Fix internal error in magic type access (``block``, ``msg``, ``tx``).
|
||||
* TypeChecker: Fix internal error when using user defined value types in public library functions.
|
||||
|
||||
|
||||
|
||||
|
@ -2559,6 +2559,11 @@ string UserDefinedValueType::toString(bool /* _short */) const
|
||||
return *definition().annotation().canonicalName;
|
||||
}
|
||||
|
||||
string UserDefinedValueType::canonicalName() const
|
||||
{
|
||||
return *definition().annotation().canonicalName;
|
||||
}
|
||||
|
||||
vector<tuple<string, Type const*>> UserDefinedValueType::makeStackItems() const
|
||||
{
|
||||
return underlyingType().stackItems();
|
||||
|
@ -1141,7 +1141,7 @@ public:
|
||||
}
|
||||
|
||||
std::string toString(bool _short) const override;
|
||||
std::string canonicalName() const override { solAssert(false, ""); }
|
||||
std::string canonicalName() const override;
|
||||
std::string signatureInExternalFunction(bool) const override { solAssert(false, ""); }
|
||||
|
||||
protected:
|
||||
|
@ -0,0 +1,28 @@
|
||||
type A is uint;
|
||||
type B is uint;
|
||||
|
||||
library L {
|
||||
function f(mapping(A=>B) storage _m, B _v) public { _m[A.wrap(uint(2))] = _v; }
|
||||
function f(mapping(uint=>uint) storage _m, uint _v) public { _m[uint(3)] = _v; }
|
||||
}
|
||||
|
||||
contract C {
|
||||
mapping(uint=>uint) uintMap;
|
||||
mapping(A=>B) abMap;
|
||||
|
||||
function testAB() public returns (bool) {
|
||||
L.f(abMap, B.wrap(3));
|
||||
return B.unwrap(abMap[A.wrap(uint(2))]) == 3;
|
||||
}
|
||||
function testUint() public returns (bool) {
|
||||
L.f(uintMap, 4);
|
||||
return uintMap[3] == 4;
|
||||
}
|
||||
}
|
||||
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// library: L
|
||||
// testAB() -> true
|
||||
// testUint() -> true
|
@ -0,0 +1,5 @@
|
||||
library L {
|
||||
function f(mapping(uint=>uint) memory) public {}
|
||||
}
|
||||
// ----
|
||||
// TypeError 4061: (25-51): Type mapping(uint256 => uint256) is only valid in storage because it contains a (nested) mapping.
|
@ -0,0 +1,6 @@
|
||||
type T is uint;
|
||||
library L {
|
||||
function f(mapping(T=>T) memory) public {}
|
||||
}
|
||||
// ----
|
||||
// TypeError 4061: (41-61): Type mapping(T => T) is only valid in storage because it contains a (nested) mapping.
|
Loading…
Reference in New Issue
Block a user