mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallow loos assembly in Solidity by permanently setting it to SyntaxError (from Warning)
This commit is contained in:
parent
6003ed2abd
commit
5d9320c70b
@ -53,6 +53,7 @@ Breaking Changes:
|
||||
* Type Checker: Fallback function must be external. This was already the case in the experimental 0.5.0 mode.
|
||||
* Type Checker: Interface functions must be declared external. This was already the case in the experimental 0.5.0 mode.
|
||||
* Type Checker: Address members are not included in contract types anymore. An explicit conversion is now required before invoking an ``address`` member from a contract.
|
||||
* Type Checker: Disallow "loose assembly" syntax entirely. This means that jump labels, jumps and non-functional instructions cannot be used anymore.
|
||||
* Remove obsolete ``std`` directory from the Solidity repository. This means accessing ``https://github.com/ethereum/soldity/blob/develop/std/*.sol`` (or ``https://github.com/ethereum/solidity/std/*.sol`` in Remix) will not be possible.
|
||||
* References Resolver: Turn missing storage locations into an error. This was already the case in the experimental 0.5.0 mode.
|
||||
* Syntax Checker: Disallow functions without implementation to use modifiers. This was already the case in the experimental 0.5.0 mode.
|
||||
|
@ -277,7 +277,7 @@ bool ReferencesResolver::visit(InlineAssembly const& _inlineAssembly)
|
||||
// Will be re-generated later with correct information
|
||||
// We use the latest EVM version because we will re-run it anyway.
|
||||
assembly::AsmAnalysisInfo analysisInfo;
|
||||
boost::optional<Error::Type> errorTypeForLoose = m_experimental050Mode ? Error::Type::SyntaxError : Error::Type::Warning;
|
||||
boost::optional<Error::Type> errorTypeForLoose = Error::Type::SyntaxError;
|
||||
assembly::AsmAnalyzer(analysisInfo, errorsIgnored, EVMVersion(), errorTypeForLoose, assembly::AsmFlavour::Loose, resolver).analyze(_inlineAssembly.operations());
|
||||
return false;
|
||||
}
|
||||
|
@ -927,15 +927,11 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
|
||||
};
|
||||
solAssert(!_inlineAssembly.annotation().analysisInfo, "");
|
||||
_inlineAssembly.annotation().analysisInfo = make_shared<assembly::AsmAnalysisInfo>();
|
||||
boost::optional<Error::Type> errorTypeForLoose =
|
||||
m_scope->sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::V050) ?
|
||||
Error::Type::SyntaxError :
|
||||
Error::Type::Warning;
|
||||
assembly::AsmAnalyzer analyzer(
|
||||
*_inlineAssembly.annotation().analysisInfo,
|
||||
m_errorReporter,
|
||||
m_evmVersion,
|
||||
errorTypeForLoose,
|
||||
Error::Type::SyntaxError,
|
||||
assembly::AsmFlavour::Loose,
|
||||
identifierAccess
|
||||
);
|
||||
|
@ -57,7 +57,7 @@ bool AsmAnalyzer::operator()(Label const& _label)
|
||||
solAssert(!_label.name.empty(), "");
|
||||
checkLooseFeature(
|
||||
_label.location,
|
||||
"The use of labels is deprecated. Please use \"if\", \"switch\", \"for\" or function calls instead."
|
||||
"The use of labels is disallowed. Please use \"if\", \"switch\", \"for\" or function calls instead."
|
||||
);
|
||||
m_info.stackHeightInfo[&_label] = m_stackHeight;
|
||||
warnOnInstructions(solidity::Instruction::JUMPDEST, _label.location);
|
||||
@ -68,7 +68,7 @@ bool AsmAnalyzer::operator()(assembly::Instruction const& _instruction)
|
||||
{
|
||||
checkLooseFeature(
|
||||
_instruction.location,
|
||||
"The use of non-functional instructions is deprecated. Please use functional notation instead."
|
||||
"The use of non-functional instructions is disallowed. Please use functional notation instead."
|
||||
);
|
||||
auto const& info = instructionInfo(_instruction.instruction);
|
||||
m_stackHeight += info.ret - info.args;
|
||||
@ -201,7 +201,7 @@ bool AsmAnalyzer::operator()(assembly::StackAssignment const& _assignment)
|
||||
{
|
||||
checkLooseFeature(
|
||||
_assignment.location,
|
||||
"The use of stack assignment is deprecated. Please use assignment in functional notation instead."
|
||||
"The use of stack assignment is disallowed. Please use assignment in functional notation instead."
|
||||
);
|
||||
bool success = checkAssignment(_assignment.variableName, size_t(-1));
|
||||
m_info.stackHeightInfo[&_assignment] = m_stackHeight;
|
||||
|
@ -6,5 +6,5 @@ contract test {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (73-74): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
|
||||
// SyntaxError: (73-74): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
|
||||
// DeclarationError: (59-84): Unbalanced stack at the end of a block: 1 surplus item(s).
|
||||
|
@ -6,5 +6,5 @@ contract test {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (73-76): The use of non-functional instructions is deprecated. Please use functional notation instead.
|
||||
// SyntaxError: (73-76): The use of non-functional instructions is deprecated. Please use functional notation instead.
|
||||
// DeclarationError: (59-86): Unbalanced stack at the end of a block: 1 missing item(s).
|
||||
|
@ -1,11 +0,0 @@
|
||||
pragma experimental "v0.5.0";
|
||||
contract C {
|
||||
function f() pure public {
|
||||
assembly {
|
||||
1
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError: (105-106): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
|
||||
// DeclarationError: (91-116): Unbalanced stack at the end of a block: 1 surplus item(s).
|
@ -6,5 +6,5 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (75-76): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
|
||||
// SyntaxError: (75-76): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
|
||||
// DeclarationError: (61-86): Unbalanced stack at the end of a block: 1 surplus item(s).
|
||||
|
@ -1,12 +0,0 @@
|
||||
pragma experimental "v0.5.0";
|
||||
contract C {
|
||||
function f() view public {
|
||||
assembly {
|
||||
address
|
||||
pop
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError: (105-112): The use of non-functional instructions is deprecated. Please use functional notation instead.
|
||||
// SyntaxError: (125-128): The use of non-functional instructions is deprecated. Please use functional notation instead.
|
@ -7,5 +7,5 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (75-82): The use of non-functional instructions is deprecated. Please use functional notation instead.
|
||||
// Warning: (95-98): The use of non-functional instructions is deprecated. Please use functional notation instead.
|
||||
// SyntaxError: (75-82): The use of non-functional instructions is deprecated. Please use functional notation instead.
|
||||
// SyntaxError: (95-98): The use of non-functional instructions is deprecated. Please use functional notation instead.
|
||||
|
@ -1,11 +0,0 @@
|
||||
pragma experimental "v0.5.0";
|
||||
contract C {
|
||||
function f() pure public {
|
||||
assembly {
|
||||
label:
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError: (105-110): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead.
|
||||
// SyntaxError: (105-110): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
|
@ -6,5 +6,5 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (75-80): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead.
|
||||
// Warning: (75-80): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
|
||||
// SyntaxError: (75-80): The use of labels is deprecated. Please use "if", "switch", "for" or function calls instead.
|
||||
// SyntaxError: (75-80): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
|
||||
|
@ -6,5 +6,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (75-82): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
|
||||
// TypeError: (75-82): Function declared as pure, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// SyntaxError: (75-82): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
|
||||
|
@ -6,5 +6,5 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (75-83): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
|
||||
// SyntaxError: (75-83): Top-level expressions are not supposed to return values (this expression returns 1 value). Use ``pop()`` or assign them.
|
||||
// DeclarationError: (61-93): Unbalanced stack at the end of a block: 1 surplus item(s).
|
||||
|
@ -4,4 +4,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (58-65): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
|
||||
// SyntaxError: (58-65): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
|
||||
|
@ -4,5 +4,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning: (63-70): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
|
||||
// TypeError: (63-70): Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.
|
||||
// SyntaxError: (63-70): Jump instructions and labels are low-level EVM features that can lead to incorrect stack access. Because of that they are discouraged. Please consider using "switch", "if" or "for" statements instead.
|
||||
|
Loading…
Reference in New Issue
Block a user