Skip to content

Commit 3ed9a38

Browse files
authored
Merge pull request #12966 from a3d4/fix-ice-structtype-nativemembers
Fix ICE caused by an immutable struct with mapping
2 parents 70ca05f + 423f3d3 commit 3ed9a38

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Bugfixes:
3636
* Common Subexpression Eliminator: Process assembly items in chunks with maximum size of 2000. It helps to avoid extremely time-consuming searches during code optimization.
3737
* Yul IR Code Generation: More robust cleanup in corner cases during memory to storage copies.
3838
* 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.
39+
* DocString Parser: Fix ICE caused by an immutable struct with mapping.
3940

4041

4142
### 0.8.14 (2022-05-17)

libsolidity/interface/CompilerStack.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -479,12 +479,6 @@ bool CompilerStack::analyze()
479479
if (auto sourceAst = source->ast)
480480
noErrors = contractLevelChecker.check(*sourceAst);
481481

482-
// Requires ContractLevelChecker
483-
DocStringAnalyser docStringAnalyser(m_errorReporter);
484-
for (Source const* source: m_sourceOrder)
485-
if (source->ast && !docStringAnalyser.analyseDocStrings(*source->ast))
486-
noErrors = false;
487-
488482
// Now we run full type checks that go down to the expression level. This
489483
// cannot be done earlier, because we need cross-contract types and information
490484
// about whether a contract is abstract for the `new` expression.
@@ -497,6 +491,15 @@ bool CompilerStack::analyze()
497491
if (source->ast && !typeChecker.checkTypeRequirements(*source->ast))
498492
noErrors = false;
499493

494+
if (noErrors)
495+
{
496+
// Requires ContractLevelChecker and TypeChecker
497+
DocStringAnalyser docStringAnalyser(m_errorReporter);
498+
for (Source const* source: m_sourceOrder)
499+
if (source->ast && !docStringAnalyser.analyseDocStrings(*source->ast))
500+
noErrors = false;
501+
}
502+
500503
if (noErrors)
501504
{
502505
// Checks that can only be done when all types of all AST nodes are known.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
contract Contract {
2+
struct S {
3+
int k;
4+
}
5+
6+
S immutable s;
7+
}
8+
// ----
9+
// TypeError 6377: (61-74): Immutable variables cannot have a non-value type.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
contract Contract {
2+
struct S {
3+
mapping(uint => address) map;
4+
}
5+
6+
S immutable s;
7+
}
8+
// ----
9+
// TypeError 6377: (84-97): Immutable variables cannot have a non-value type.

0 commit comments

Comments
 (0)