Merge pull request #12966 from a3d4/fix-ice-structtype-nativemembers

Fix ICE caused by an immutable struct with mapping
This commit is contained in:
Mathias L. Baumann 2022-06-23 16:11:28 +02:00 committed by GitHub
commit 3ed9a38abc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 6 deletions

View File

@ -36,6 +36,7 @@ Bugfixes:
* Common Subexpression Eliminator: Process assembly items in chunks with maximum size of 2000. It helps to avoid extremely time-consuming searches during code optimization. * Common Subexpression Eliminator: Process assembly items in chunks with maximum size of 2000. It helps to avoid extremely time-consuming searches during code optimization.
* Yul IR Code Generation: More robust cleanup in corner cases during memory to storage copies. * Yul IR Code Generation: More robust cleanup in corner cases during memory to storage copies.
* Yul Optimizer: Do not remove ``returndatacopy`` in cases in which it might perform out-of-bounds reads that unconditionally revert as out-of-gas. Previously, any ``returndatacopy`` that wrote to memory that was never read from was removed without accounting for the out-of-bounds condition. * Yul Optimizer: Do not remove ``returndatacopy`` in cases in which it might perform out-of-bounds reads that unconditionally revert as out-of-gas. Previously, any ``returndatacopy`` that wrote to memory that was never read from was removed without accounting for the out-of-bounds condition.
* DocString Parser: Fix ICE caused by an immutable struct with mapping.
### 0.8.14 (2022-05-17) ### 0.8.14 (2022-05-17)

View File

@ -479,12 +479,6 @@ bool CompilerStack::analyze()
if (auto sourceAst = source->ast) if (auto sourceAst = source->ast)
noErrors = contractLevelChecker.check(*sourceAst); noErrors = contractLevelChecker.check(*sourceAst);
// Requires ContractLevelChecker
DocStringAnalyser docStringAnalyser(m_errorReporter);
for (Source const* source: m_sourceOrder)
if (source->ast && !docStringAnalyser.analyseDocStrings(*source->ast))
noErrors = false;
// Now we run full type checks that go down to the expression level. This // Now we run full type checks that go down to the expression level. This
// cannot be done earlier, because we need cross-contract types and information // cannot be done earlier, because we need cross-contract types and information
// about whether a contract is abstract for the `new` expression. // about whether a contract is abstract for the `new` expression.
@ -497,6 +491,15 @@ bool CompilerStack::analyze()
if (source->ast && !typeChecker.checkTypeRequirements(*source->ast)) if (source->ast && !typeChecker.checkTypeRequirements(*source->ast))
noErrors = false; noErrors = false;
if (noErrors)
{
// Requires ContractLevelChecker and TypeChecker
DocStringAnalyser docStringAnalyser(m_errorReporter);
for (Source const* source: m_sourceOrder)
if (source->ast && !docStringAnalyser.analyseDocStrings(*source->ast))
noErrors = false;
}
if (noErrors) if (noErrors)
{ {
// Checks that can only be done when all types of all AST nodes are known. // Checks that can only be done when all types of all AST nodes are known.

View File

@ -0,0 +1,9 @@
contract Contract {
struct S {
int k;
}
S immutable s;
}
// ----
// TypeError 6377: (61-74): Immutable variables cannot have a non-value type.

View File

@ -0,0 +1,9 @@
contract Contract {
struct S {
mapping(uint => address) map;
}
S immutable s;
}
// ----
// TypeError 6377: (84-97): Immutable variables cannot have a non-value type.