Skip to content

Commit 423f3d3

Browse files
a3d4wechman
authored andcommitted
Fix ICE caused by an immutable struct
1 parent 3948391 commit 423f3d3

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
@@ -13,6 +13,7 @@ Compiler Features:
1313
Bugfixes:
1414
* ABI Encoder: When encoding an empty string coming from storage do not add a superfluous empty slot for data.
1515
* 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.
16+
* DocString Parser: Fix ICE caused by an immutable struct with mapping.
1617

1718

1819
### 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)