Extract yul syntax tests: invalid use of builtin identifiers

This commit is contained in:
Christian Parpart 2020-10-14 12:18:33 +02:00
parent 5d40494ed2
commit 626b7cdb09
6 changed files with 25 additions and 19 deletions

View File

@ -126,25 +126,6 @@ do \
BOOST_AUTO_TEST_SUITE(YulParser) BOOST_AUTO_TEST_SUITE(YulParser)
BOOST_AUTO_TEST_CASE(builtins_parser)
{
struct SimpleDialect: public Dialect
{
BuiltinFunction const* builtin(YulString _name) const override
{
return _name == "builtin"_yulstring ? &f : nullptr;
}
BuiltinFunction f;
};
SimpleDialect dialect;
CHECK_ERROR_DIALECT("{ let builtin := 6 }", ParserError, "Cannot use builtin function name \"builtin\" as identifier name.", dialect);
CHECK_ERROR_DIALECT("{ function builtin() {} }", ParserError, "Cannot use builtin function name \"builtin\" as identifier name.", dialect);
CHECK_ERROR_DIALECT("{ function f(x) { f(builtin) } }", ParserError, "Expected '(' but got ')'", dialect);
CHECK_ERROR_DIALECT("{ function f(builtin) {}", ParserError, "Cannot use builtin function name \"builtin\" as identifier name.", dialect);
CHECK_ERROR_DIALECT("{ function f() -> builtin {}", ParserError, "Cannot use builtin function name \"builtin\" as identifier name.", dialect);
}
BOOST_AUTO_TEST_CASE(builtins_analysis) BOOST_AUTO_TEST_CASE(builtins_analysis)
{ {
struct SimpleDialect: public Dialect struct SimpleDialect: public Dialect

View File

@ -0,0 +1,5 @@
{
let add := 6
}
// ----
// ParserError 5568: (7-10): Cannot use builtin function name "add" as identifier name.

View File

@ -0,0 +1,5 @@
{
function add() {}
}
// ----
// ParserError 5568: (12-15): Cannot use builtin function name "add" as identifier name.

View File

@ -0,0 +1,5 @@
{
function f(x) { f(add) }
}
// ----
// ParserError 2314: (24-25): Expected '(' but got ')'

View File

@ -0,0 +1,5 @@
{
function f(add) {}
}
// ----
// ParserError 5568: (14-17): Cannot use builtin function name "add" as identifier name.

View File

@ -0,0 +1,5 @@
{
function f() -> add {}
}
// ----
// ParserError 5568: (19-22): Cannot use builtin function name "add" as identifier name.