aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libsolidity/ExpressionCompiler.cpp10
-rw-r--r--test/libsolidity/SolidityEndToEndTest.cpp15
2 files changed, 25 insertions, 0 deletions
diff --git a/libsolidity/ExpressionCompiler.cpp b/libsolidity/ExpressionCompiler.cpp
index fde88a00..112521f9 100644
--- a/libsolidity/ExpressionCompiler.cpp
+++ b/libsolidity/ExpressionCompiler.cpp
@@ -950,6 +950,12 @@ bool ExpressionCompiler::visit(IndexAccess const& _indexAccess)
break;
}
}
+ else if (baseType.category() == Type::Category::TypeType)
+ {
+ solAssert(baseType.sizeOnStack() == 0, "");
+ solAssert(_indexAccess.annotation().type->sizeOnStack() == 0, "");
+ // no-op - this seems to be a lone array type (`structType[];`)
+ }
else
solAssert(false, "Index access only allowed for mappings or arrays.");
@@ -1003,6 +1009,10 @@ void ExpressionCompiler::endVisit(Identifier const& _identifier)
{
// no-op
}
+ else if (dynamic_cast<StructDefinition const*>(declaration))
+ {
+ // no-op
+ }
else
{
BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Identifier type not expected in expression context."));
diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp
index 75e43b73..27c511f2 100644
--- a/test/libsolidity/SolidityEndToEndTest.cpp
+++ b/test/libsolidity/SolidityEndToEndTest.cpp
@@ -5772,6 +5772,21 @@ BOOST_AUTO_TEST_CASE(destructuring_assignment_wildcard)
BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(0)));
}
+BOOST_AUTO_TEST_CASE(lone_struct_array_type)
+{
+ char const* sourceCode = R"(
+ contract C {
+ struct s { uint a; uint b;}
+ function f() returns (uint) {
+ s[7][]; // This is only the type, should not have any effect
+ return 3;
+ }
+ }
+ )";
+ compileAndRun(sourceCode);
+ BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(3)));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}