mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Extract yul syntax tests: invalid use of builtin identifiers
This commit is contained in:
parent
5d40494ed2
commit
626b7cdb09
@ -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
|
||||||
|
5
test/libyul/yulSyntaxTests/builtin_identifier_1.yul
Normal file
5
test/libyul/yulSyntaxTests/builtin_identifier_1.yul
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
let add := 6
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 5568: (7-10): Cannot use builtin function name "add" as identifier name.
|
5
test/libyul/yulSyntaxTests/builtin_identifier_2.yul
Normal file
5
test/libyul/yulSyntaxTests/builtin_identifier_2.yul
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
function add() {}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 5568: (12-15): Cannot use builtin function name "add" as identifier name.
|
5
test/libyul/yulSyntaxTests/builtin_identifier_3.yul
Normal file
5
test/libyul/yulSyntaxTests/builtin_identifier_3.yul
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
function f(x) { f(add) }
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 2314: (24-25): Expected '(' but got ')'
|
5
test/libyul/yulSyntaxTests/builtin_identifier_4.yul
Normal file
5
test/libyul/yulSyntaxTests/builtin_identifier_4.yul
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
function f(add) {}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 5568: (14-17): Cannot use builtin function name "add" as identifier name.
|
5
test/libyul/yulSyntaxTests/builtin_identifier_5.yul
Normal file
5
test/libyul/yulSyntaxTests/builtin_identifier_5.yul
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
function f() -> add {}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// ParserError 5568: (19-22): Cannot use builtin function name "add" as identifier name.
|
Loading…
Reference in New Issue
Block a user