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

ICE in StructType::isDynamicallyEncoded() when a function has a calldata struct argument with an internal type inside :: Issue 11610 #12266

Closed
wants to merge 1 commit into from

Conversation

nishant-sachdeva
Copy link
Contributor

@nishant-sachdeva nishant-sachdeva commented Nov 10, 2021

TypeChecker.cpp :: Replced typeError with fataTypeError in lines 390 and 406.
Test file added in test/libsolidity/syntaxTests/calldata_struct_argument_with_internal_type_inside.sol
Relevant line added to Changelog.md

Closes #11610

…06. Test file added in test/libsolidity/syntaxTests/calldata_struct_argument_with_internal_type_inside.sol
@nishant-sachdeva nishant-sachdeva changed the title Issue 11610 : Replced typeError with fataTypeError in lines 390 and 4… Issue 11610 Nov 10, 2021
@nishant-sachdeva nishant-sachdeva changed the title Issue 11610 Draft PR :: Issue 11610 Nov 10, 2021
Copy link
Member

@cameel cameel left a comment

Choose a reason for hiding this comment

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

Congrats on the first PR!

I added some remarks for specific places in code in the comments below. Here are some general ones:

  • I'd avoid making PRs from develop branch in your fork. It just makes it harder to update it or make multiple PRs. Please use named branches instead.
  • Please use some sensible title for the PR (and a similar name for the branch). We generally don't know all issue numbers by heart so it's hard to say what it's about without looking it up :P In branch names the issue number also would make it annoying to type on the CLI because you have to type the number before you get autocompletion. Also no need to say "Draft" in the title.

@@ -29,6 +29,7 @@ Bugfixes:
* TypeChecker: Improved error message for constant variables with (nested) mapping types.
* Yul Assembler: Fix internal error when function names are not unique.
* Yul IR Generator: Do not output empty switches/if-bodies for empty contracts.
* ICE in StructType::isDynamicallyEncoded() when a function has a calldata struct argument with an internal type inside
Copy link
Member

Choose a reason for hiding this comment

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

Please rebase on latest develop. We have just relased 0.8.10 yesterday so this should be in the 0.8.11 section :)

Comment on lines +1 to +6
contract C {
struct S {
function() a;
}
function f(S[2] calldata) {}
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
contract C {
struct S {
function() a;
}
function f(S[2] calldata) {}
}
contract C {
struct S {
function() a;
}
function f(S[2] calldata) {}
}

@@ -0,0 +1,9 @@
contract C {
Copy link
Member

Choose a reason for hiding this comment

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

Unless the test is really unique in some way, I think it would be better to find a subdirectory where it fits best instead of dropping it directly into syntaxTests/.

I'd place it next to the test from #10516.

@@ -29,6 +29,7 @@ Bugfixes:
* TypeChecker: Improved error message for constant variables with (nested) mapping types.
* Yul Assembler: Fix internal error when function names are not unique.
* Yul IR Generator: Do not output empty switches/if-bodies for empty contracts.
* ICE in StructType::isDynamicallyEncoded() when a function has a calldata struct argument with an internal type inside
Copy link
Member

Choose a reason for hiding this comment

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

Does it happen for calldata structs or only for arrays of structs? Can you add a test case covering single structs (unless there's one already, please check)?

Copy link
Contributor Author

@nishant-sachdeva nishant-sachdeva Nov 11, 2021

Choose a reason for hiding this comment

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

@cameel You've mentioned in #10516 that this works for a struct but not for an array of structs.
This is because isDynamicallyEncoded() does not get called in the first case case.

However, I've added a test case to check for a single struct. Will push in the next commit.

@@ -387,7 +387,7 @@ bool TypeChecker::visit(FunctionDefinition const& _function)
_var.referenceLocation() == VariableDeclaration::Location::Storage &&
!m_currentContract->abstract()
)
m_errorReporter.typeError(
m_errorReporter.fatalTypeError(
Copy link
Member

Choose a reason for hiding this comment

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

This generally seems fine to me but please check if it shouldn't rather be fixed in the same place as #11000 instead.

@cameel
Copy link
Member

cameel commented Nov 10, 2021

About your question from the call: you need to update test expectations (isoltest can do it automatically), which will remove the error from some tests but after doing that please make sure that every test still makes sense. If stopping early makes it ineffective at testing what it was supposed to (i.e. it should produce a specific error message that no longer shows up), it may have to be adjusted.

function f(S[2] calldata) {}
}
// ----
// SyntaxError 4937: (50-78): No visibility specified. Did you intend to add "public"?
Copy link
Contributor

Choose a reason for hiding this comment

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

Please make the function public (function <functionName>() public ...) so that this error goes away - it is not relevant for the test.

@nishant-sachdeva nishant-sachdeva changed the title Draft PR :: Issue 11610 Draft PR :: Issue 11610 :: ICE in StructType::isDynamicallyEncoded() when a function has a calldata struct argument with an internal type inside Nov 11, 2021
@nishant-sachdeva nishant-sachdeva changed the title Draft PR :: Issue 11610 :: ICE in StructType::isDynamicallyEncoded() when a function has a calldata struct argument with an internal type inside ICE in StructType::isDynamicallyEncoded() when a function has a calldata struct argument with an internal type inside :: Issue 11610 Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants