Repository navigation
Deduplicate error messages for memory or calldata types containing nested mappings - #17342
Conversation
blishko
left a comment
There was a problem hiding this comment.
Looks good! Can you just explain the assert?
| "Type " + referenceType->toString(true) + " is only valid in storage because it contains a (nested) mapping." | ||
| ); | ||
| else if (auto result = validForLocation(referenceType, referenceType->location()); !result) | ||
| solAssert(!actualType->fullEncodingType(false)); |
There was a problem hiding this comment.
I don't see why this is the correct assert here. Can you explain it? Maybe add an error message to the assert?
There was a problem hiding this comment.
Yeah, it's because here location is Memory (see the assert before in lines 151 to 152), which cannot accept nested mappings, so the type cannot be encoded and the previous check and error message 9611 should have been triggered...
Could also check explicitly for the error code:
| solAssert(!actualType->fullEncodingType(false)); | |
| solAssert(m_errorReporter.hasError(ErrorId{9611})); |
But I think adding a message to the assert would be better:
solAssert(!actualType->fullEncodingType(false), "Type is only valid in storage because it has a nested mapping (cannot be abi encoded)")
There was a problem hiding this comment.
I think adding a message is better, but maybe we can include the information about 9611.
How about
solAssert(!actualType->fullEncodingType(false), "Types containing (nested) mappings have no ABI encoding, error 9611 should have been reported)"?
There was a problem hiding this comment.
Agreed. Done.
dbe38c0 to
8982bec
Compare
Follow-up for #17290.
Remove redundant errors for types not declared in storage that contains nested mapping.