Skip to content

Deduplicate error messages for memory or calldata types containing nested mappings - #17342

Merged
blishko merged 2 commits into
developfrom
remove-redundant-error-messages
Dec 2, 2026
Merged

blishko merged 2 commits into
developfrom
remove-redundant-error-messages

Conversation

@matheusaaguiar

Copy link
Copy Markdown
Contributor

Follow-up for #17290.
Remove redundant errors for types not declared in storage that contains nested mapping.

@blishko blishko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Can you just explain the assert?

Comment thread libsolidity/analysis/TypeChecker.cpp Outdated
"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));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why this is the correct assert here. Can you explain it? Maybe add an error message to the assert?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Suggested change
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)")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Done.

@matheusaaguiar
matheusaaguiar force-pushed the remove-redundant-error-messages branch from dbe38c0 to 8982bec Compare December 2, 2026 16:19

@blishko blishko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@blishko
blishko merged commit ad96b4e into develop Dec 2, 2026
82 checks passed
@blishko
blishko deleted the remove-redundant-error-messages branch December 2, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants