Raise error on oversized number literals in assembly

This commit is contained in:
Alex Beregszaszi 2018-01-04 23:25:41 +00:00
parent d01786f0aa
commit ae02bb5aad
4 changed files with 11 additions and 0 deletions

View File

@ -6,6 +6,7 @@ Features:
* Type Checker: Disallow uninitialized storage pointers as experimental 0.5.0 feature.
Bugfixes:
* Assembly: Raise error on oversized number literals in assembly.
* JSON-AST: Add "documentation" property to function, event and modifier definition.
* Resolver: Properly determine shadowing for imports with aliases.
* Standalone Assembly: Do not ignore input after closing brace of top level block.

View File

@ -82,6 +82,14 @@ bool AsmAnalyzer::operator()(assembly::Literal const& _literal)
);
return false;
}
else if (_literal.kind == assembly::LiteralKind::Number && bigint(_literal.value) > u256(-1))
{
m_errorReporter.typeError(
_literal.location,
"Number literal too large (> 256 bits)"
);
return false;
}
m_info.stackHeightInfo[&_literal] = m_stackHeight;
return true;
}

View File

@ -228,6 +228,7 @@ BOOST_AUTO_TEST_CASE(number_literals)
CHECK_ERROR("{ let x:u256 := .1:u256 }", ParserError, "Invalid number literal.");
CHECK_ERROR("{ let x:u256 := 1e5:u256 }", ParserError, "Invalid number literal.");
CHECK_ERROR("{ let x:u256 := 67.235:u256 }", ParserError, "Invalid number literal.");
CHECK_ERROR("{ let x:u256 := 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff:u256 }", TypeError, "Number literal too large (> 256 bits)");
}
BOOST_AUTO_TEST_CASE(builtin_types)

View File

@ -390,6 +390,7 @@ BOOST_AUTO_TEST_CASE(number_literals)
CHECK_PARSE_ERROR("{ let x := .1 }", ParserError, "Invalid number literal.");
CHECK_PARSE_ERROR("{ let x := 1e5 }", ParserError, "Invalid number literal.");
CHECK_PARSE_ERROR("{ let x := 67.235 }", ParserError, "Invalid number literal.");
CHECK_STRICT_ERROR("{ let x := 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff }", TypeError, "Number literal too large (> 256 bits)");
}
BOOST_AUTO_TEST_CASE(function_definitions)