Skip to content

Commit c967d46

Browse files
authored
Merge pull request #15218 from ethereum/fix-transient-storage-allowing-passthrough
Error out on transient usage in TypeChecker
2 parents ce4be6e + dd60886 commit c967d46

14 files changed

+89
-28
lines changed

libsolidity/analysis/TypeChecker.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,13 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
478478
Type const* varType = _variable.annotation().type;
479479
solAssert(!!varType, "Variable type not provided.");
480480

481+
if (_variable.referenceLocation() == VariableDeclaration::Location::Transient)
482+
m_errorReporter.unimplementedFeatureError(
483+
6715_error,
484+
_variable.location(),
485+
"Transient storage is not yet implemented."
486+
);
487+
481488
if (_variable.value())
482489
{
483490
if (_variable.isStateVariable() && varType->containsNestedMapping())

libsolidity/codegen/ContractCompiler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,11 @@ void ContractCompiler::initializeStateVariables(ContractDefinition const& _contr
585585
{
586586
solAssert(!_contract.isLibrary(), "Tried to initialize state variables of library.");
587587
for (VariableDeclaration const* variable: _contract.stateVariables())
588+
{
589+
solUnimplementedAssert(variable->referenceLocation() != VariableDeclaration::Location::Transient, "Transient storage variables not supported.");
588590
if (variable->value() && !variable->isConstant())
589591
ExpressionCompiler(m_context, m_optimiserSettings.runOrderLiterals).appendStateVariableInitialization(*variable);
592+
}
590593
}
591594

592595
bool ContractCompiler::visit(VariableDeclaration const& _variableDeclaration)

libsolidity/codegen/ir/IRGenerator.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,8 +821,11 @@ std::string IRGenerator::initStateVariables(ContractDefinition const& _contract)
821821
{
822822
IRGeneratorForStatements generator{m_context, m_utils, m_optimiserSettings};
823823
for (VariableDeclaration const* variable: _contract.stateVariables())
824+
{
825+
solUnimplementedAssert(variable->referenceLocation() != VariableDeclaration::Location::Transient, "Transient storage variables not supported.");
824826
if (!variable->isConstant())
825827
generator.initializeStateVar(*variable);
828+
}
826829

827830
return generator.code();
828831
}

test/cmdlineTests/storage_layout_transient_value_types/output.json

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,61 @@
22
"errors": [
33
{
44
"component": "general",
5-
"formattedMessage": "Transient storage layout is not supported yet.",
6-
"message": "Transient storage layout is not supported yet.",
5+
"errorCode": "6715",
6+
"formattedMessage": "UnimplementedFeatureError: Transient storage is not yet implemented.
7+
--> fileA:4:5:
8+
|
9+
4 | uint transient x;
10+
| ^^^^^^^^^^^^^^^^
11+
12+
",
13+
"message": "Transient storage is not yet implemented.",
714
"severity": "error",
15+
"sourceLocation": {
16+
"end": 91,
17+
"file": "fileA",
18+
"start": 75
19+
},
20+
"type": "UnimplementedFeatureError"
21+
},
22+
{
23+
"component": "general",
24+
"errorCode": "6715",
25+
"formattedMessage": "UnimplementedFeatureError: Transient storage is not yet implemented.
26+
--> fileA:6:5:
27+
|
28+
6 | bytes32 transient b;
29+
| ^^^^^^^^^^^^^^^^^^^
30+
31+
",
32+
"message": "Transient storage is not yet implemented.",
33+
"severity": "error",
34+
"sourceLocation": {
35+
"end": 128,
36+
"file": "fileA",
37+
"start": 109
38+
},
39+
"type": "UnimplementedFeatureError"
40+
},
41+
{
42+
"component": "general",
43+
"errorCode": "6715",
44+
"formattedMessage": "UnimplementedFeatureError: Transient storage is not yet implemented.
45+
--> fileA:8:5:
46+
|
47+
8 | address transient a;
48+
| ^^^^^^^^^^^^^^^^^^^
49+
50+
",
51+
"message": "Transient storage is not yet implemented.",
52+
"severity": "error",
53+
"sourceLocation": {
54+
"end": 168,
55+
"file": "fileA",
56+
"start": 149
57+
},
858
"type": "UnimplementedFeatureError"
959
}
10-
]
60+
],
61+
"sources": {}
1162
}

test/libsolidity/astPropertyTests/transient_data_location.sol

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/libsolidity/smtCheckerTests/unsupported/transient_storage_state_variable.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ contract C {
55
// ====
66
// SMTEngine: all
77
// ----
8-
// UnimplementedFeatureError 1834: Transient storage variables are not supported.
8+
// UnimplementedFeatureError 6715: (17-38): Transient storage is not yet implemented.
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
contract C {
22
uint[] transient x;
33
}
4-
// ====
5-
// stopAfter: analysis
64
// ----
75
// UnimplementedFeatureError 1834: Transient data location is only supported for value types.
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
contract C {
22
uint[3] transient x;
33
}
4-
// ====
5-
// stopAfter: analysis
64
// ----
75
// UnimplementedFeatureError 1834: Transient data location is only supported for value types.

test/libsolidity/syntaxTests/dataLocations/transient_function_type.sol

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ contract C {
66
function () internal transient internal fiti;
77
function () internal internal transient fiit;
88
}
9-
// ====
10-
// stopAfter: analysis
119
// ----
10+
// UnimplementedFeatureError 6715: (17-40): Transient storage is not yet implemented.
11+
// UnimplementedFeatureError 6715: (46-82): Transient storage is not yet implemented.
12+
// UnimplementedFeatureError 6715: (88-122): Transient storage is not yet implemented.
13+
// UnimplementedFeatureError 6715: (128-162): Transient storage is not yet implemented.
14+
// UnimplementedFeatureError 6715: (168-212): Transient storage is not yet implemented.
15+
// UnimplementedFeatureError 6715: (218-262): Transient storage is not yet implemented.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
contract C {
22
mapping(uint => uint) transient y;
33
}
4-
// ====
5-
// stopAfter: analysis
4+
65
// ----
76
// UnimplementedFeatureError 1834: Transient data location is only supported for value types.

0 commit comments

Comments
 (0)