Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ICE caused by an array of mappings #9702

Merged
merged 1 commit into from
Sep 30, 2020

Conversation

a3d4
Copy link
Contributor

@a3d4 a3d4 commented Aug 30, 2020

Fixes #7410 by disallowing .push(<arg>) for storage arrays with mappings.

@chriseth @leonardoalt @hrkrshnn

From the #7410 discussion, I somewhat concluded that the idea is to forbid arrays with (nested) mappings.

I added a simple check and updated several test cases (more needs to be updated). Is it the intended direction? The impact (in terms of the number of failing tests) is rather big.

Disallows .push(<arg>) and .pop() for storage arrays with nested mappings.

@chriseth
Copy link
Contributor

I don't think we should disallow them - sorry :)

@a3d4
Copy link
Contributor Author

a3d4 commented Aug 31, 2020

I don't think we should disallow them - sorry :)

Should we move #7410 back from the implementation backlog then? Or is there a consensus how to proceed?

@hrkrshnn
Copy link
Member

One way to proceed is to disallow push and pop for arrays (state variables) containing mappings.

@cameel
Copy link
Member

cameel commented Sep 2, 2020

@hrkrshnn I just noticed that we already have an issue about that in the design backlog so it's probably the way to go: #8535.

@a3d4 a3d4 force-pushed the fix-7410-arrays-of-mappings branch from cb49b91 to d575941 Compare September 27, 2020 19:41
Comment on lines 2685 to 2691
if (
((funType->kind() == FunctionType::Kind::ArrayPush && arguments.value().numArguments() != 0) || funType->kind() == FunctionType::Kind::ArrayPop) &&
exprType->containsNestedMapping()
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if (
    auto arrayType = dynamic_cast<ArrayType const*>(exprType);
	arrayType &&
	arrayType->location() == DataLocation::Storage &&
	arrayType->containsNestedMapping() &&
	((memberName == "push" && arguments.value().numArguments() != 0) || memberName == "pop")
)

Would this be better?

@a3d4
Copy link
Contributor Author

a3d4 commented Sep 27, 2020

Several tests fail because of .pop(). Should I push to breaking?

@a3d4 a3d4 requested a review from chriseth September 27, 2020 20:40
@chriseth
Copy link
Contributor

Disallowing .push(<arg>) is a bugfix to develop. Disallowing .pop() should be a feature for breaking (if we want it).

Just out of curiosity: .push() is fine, right?

@a3d4 a3d4 force-pushed the fix-7410-arrays-of-mappings branch from d575941 to e18652f Compare September 29, 2020 16:00
@a3d4 a3d4 force-pushed the fix-7410-arrays-of-mappings branch from e18652f to 3c876fc Compare September 29, 2020 16:18
@a3d4
Copy link
Contributor Author

a3d4 commented Sep 29, 2020

.push() is fine, right?

In the sense that it does not crash the compiler, yes.

@a3d4 a3d4 marked this pull request as ready for review September 29, 2020 16:40
@chriseth chriseth merged commit 3af21c9 into ethereum:develop Sep 30, 2020
@a3d4 a3d4 deleted the fix-7410-arrays-of-mappings branch October 5, 2020 13:14
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.

ICE on push to array with storage mapping
4 participants