Merge pull request #7712 from ethereum/fixIstanbulAsmParsing

Fix assembly parsing by passing evm version.
This commit is contained in:
chriseth
2019-11-14 13:20:15 +01:00
committed by GitHub
9 changed files with 37 additions and 10 deletions
+1 -1
View File
@@ -64,7 +64,7 @@ eth::AssemblyItems compileContract(std::shared_ptr<CharStream> _sourceCode)
map<ASTNode const*, shared_ptr<DeclarationContainer>> scopes;
GlobalContext globalContext;
NameAndTypeResolver resolver(globalContext, scopes, errorReporter);
NameAndTypeResolver resolver(globalContext, dev::test::Options::get().evmVersion(), scopes, errorReporter);
solAssert(Error::containsOnlyWarnings(errorReporter.errors()), "");
resolver.registerDeclarations(*sourceUnit);
for (ASTPointer<ASTNode> const& node: sourceUnit->nodes())
@@ -118,7 +118,7 @@ bytes compileFirstExpression(
ErrorReporter errorReporter(errors);
GlobalContext globalContext;
map<ASTNode const*, shared_ptr<DeclarationContainer>> scopes;
NameAndTypeResolver resolver(globalContext, scopes, errorReporter);
NameAndTypeResolver resolver(globalContext, dev::test::Options::get().evmVersion(), scopes, errorReporter);
resolver.registerDeclarations(*sourceUnit);
vector<ContractDefinition const*> inheritanceHierarchy;
@@ -1,12 +1,12 @@
contract C {
function f() pure external {
function f() pure external returns (uint id) {
assembly {
pop(chainid())
id := chainid()
}
}
function g() view external {
function g() view external returns (uint sb) {
assembly {
pop(selfbalance())
sb := selfbalance()
}
}
}
@@ -0,0 +1,17 @@
contract C {
function f() pure external returns (uint id) {
assembly {
id := chainid()
}
}
function g() view external returns (uint sb) {
assembly {
sb := selfbalance()
}
}
}
// ====
// EVMVersion: =petersburg
// ----
// TypeError: (101-110): The "chainid" instruction is only available for Istanbul-compatible VMs (you are currently compiling for "petersburg").
// TypeError: (215-228): The "selfbalance" instruction is only available for Istanbul-compatible VMs (you are currently compiling for "petersburg").