mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-15 06:15:44 +08:00
parent
a7299c3f0f
commit
39d2c295e7
@ -797,7 +797,7 @@ AstStat* Parser::parseAttributeStat()
|
||||
}
|
||||
default:
|
||||
return reportStatError(lexer.current().location, {}, {},
|
||||
"Expected 'function', 'local function', 'declare function' or a function type declaration after attribute, but got %s intead",
|
||||
"Expected 'function', 'local function', 'declare function' or a function type declaration after attribute, but got %s instead",
|
||||
lexer.current().toString().c_str());
|
||||
}
|
||||
}
|
||||
@ -836,7 +836,7 @@ AstStat* Parser::parseLocal(const AstArray<AstAttr*>& attributes)
|
||||
{
|
||||
if (FFlag::LuauAttributeSyntax && attributes.size != 0)
|
||||
{
|
||||
return reportStatError(lexer.current().location, {}, {}, "Expected 'function' after local declaration with attribute, but got %s intead",
|
||||
return reportStatError(lexer.current().location, {}, {}, "Expected 'function' after local declaration with attribute, but got %s instead",
|
||||
lexer.current().toString().c_str());
|
||||
}
|
||||
|
||||
@ -981,7 +981,7 @@ AstStat* Parser::parseDeclaration(const Location& start, const AstArray<AstAttr*
|
||||
// `declare` token is already parsed at this point
|
||||
|
||||
if (FFlag::LuauAttributeSyntax && (attributes.size != 0) && (lexer.current().type != Lexeme::ReservedFunction))
|
||||
return reportStatError(lexer.current().location, {}, {}, "Expected a function type declaration after attribute, but got %s intead",
|
||||
return reportStatError(lexer.current().location, {}, {}, "Expected a function type declaration after attribute, but got %s instead",
|
||||
lexer.current().toString().c_str());
|
||||
|
||||
if (lexer.current().type == Lexeme::ReservedFunction)
|
||||
@ -2438,7 +2438,7 @@ AstExpr* Parser::parseSimpleExpr()
|
||||
if (lexer.current().type != Lexeme::ReservedFunction)
|
||||
{
|
||||
return reportExprError(
|
||||
start, {}, "Expected 'function' declaration after attribute, but got %s intead", lexer.current().toString().c_str());
|
||||
start, {}, "Expected 'function' declaration after attribute, but got %s instead", lexer.current().toString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3334,7 +3334,7 @@ TEST_CASE_FIXTURE(Fixture, "dont_parse_attributes_on_non_function_stat")
|
||||
@checked
|
||||
if a<0 then a = 0 end)");
|
||||
checkFirstErrorForAttributes(pr1.errors, 1, Location(Position(2, 0), Position(2, 2)),
|
||||
"Expected 'function', 'local function', 'declare function' or a function type declaration after attribute, but got 'if' intead");
|
||||
"Expected 'function', 'local function', 'declare function' or a function type declaration after attribute, but got 'if' instead");
|
||||
|
||||
ParseResult pr2 = tryParse(R"(
|
||||
local i = 1
|
||||
@ -3344,7 +3344,7 @@ while a[i] do
|
||||
i = i + 1
|
||||
end)");
|
||||
checkFirstErrorForAttributes(pr2.errors, 1, Location(Position(3, 0), Position(3, 5)),
|
||||
"Expected 'function', 'local function', 'declare function' or a function type declaration after attribute, but got 'while' intead");
|
||||
"Expected 'function', 'local function', 'declare function' or a function type declaration after attribute, but got 'while' instead");
|
||||
|
||||
ParseResult pr3 = tryParse(R"(
|
||||
@checked
|
||||
@ -3355,14 +3355,14 @@ do
|
||||
x2 = (-b - d)/a2
|
||||
end)");
|
||||
checkFirstErrorForAttributes(pr3.errors, 1, Location(Position(2, 0), Position(2, 2)),
|
||||
"Expected 'function', 'local function', 'declare function' or a function type declaration after attribute, but got 'do' intead");
|
||||
"Expected 'function', 'local function', 'declare function' or a function type declaration after attribute, but got 'do' instead");
|
||||
|
||||
ParseResult pr4 = tryParse(R"(
|
||||
@checked
|
||||
for i=1,10 do print(i) end
|
||||
)");
|
||||
checkFirstErrorForAttributes(pr4.errors, 1, Location(Position(2, 0), Position(2, 3)),
|
||||
"Expected 'function', 'local function', 'declare function' or a function type declaration after attribute, but got 'for' intead");
|
||||
"Expected 'function', 'local function', 'declare function' or a function type declaration after attribute, but got 'for' instead");
|
||||
|
||||
ParseResult pr5 = tryParse(R"(
|
||||
@checked
|
||||
@ -3371,7 +3371,7 @@ repeat
|
||||
until line ~= ""
|
||||
)");
|
||||
checkFirstErrorForAttributes(pr5.errors, 1, Location(Position(2, 0), Position(2, 6)),
|
||||
"Expected 'function', 'local function', 'declare function' or a function type declaration after attribute, but got 'repeat' intead");
|
||||
"Expected 'function', 'local function', 'declare function' or a function type declaration after attribute, but got 'repeat' instead");
|
||||
|
||||
|
||||
ParseResult pr6 = tryParse(R"(
|
||||
@ -3379,7 +3379,7 @@ until line ~= ""
|
||||
local x = 10
|
||||
)");
|
||||
checkFirstErrorForAttributes(
|
||||
pr6.errors, 1, Location(Position(2, 6), Position(2, 7)), "Expected 'function' after local declaration with attribute, but got 'x' intead");
|
||||
pr6.errors, 1, Location(Position(2, 6), Position(2, 7)), "Expected 'function' after local declaration with attribute, but got 'x' instead");
|
||||
|
||||
ParseResult pr7 = tryParse(R"(
|
||||
local i = 1
|
||||
@ -3389,14 +3389,14 @@ while a[i] do
|
||||
end
|
||||
)");
|
||||
checkFirstErrorForAttributes(pr7.errors, 1, Location(Position(3, 31), Position(3, 36)),
|
||||
"Expected 'function', 'local function', 'declare function' or a function type declaration after attribute, but got 'break' intead");
|
||||
"Expected 'function', 'local function', 'declare function' or a function type declaration after attribute, but got 'break' instead");
|
||||
|
||||
|
||||
ParseResult pr8 = tryParse(R"(
|
||||
function foo1 () @checked return 'a' end
|
||||
)");
|
||||
checkFirstErrorForAttributes(pr8.errors, 1, Location(Position(1, 26), Position(1, 32)),
|
||||
"Expected 'function', 'local function', 'declare function' or a function type declaration after attribute, but got 'return' intead");
|
||||
"Expected 'function', 'local function', 'declare function' or a function type declaration after attribute, but got 'return' instead");
|
||||
}
|
||||
|
||||
TEST_CASE_FIXTURE(Fixture, "dont_parse_attribute_on_argument_non_function")
|
||||
@ -3412,7 +3412,7 @@ invoker(function(x) return (x + 2) end, @checked 1)
|
||||
)");
|
||||
|
||||
checkFirstErrorForAttributes(
|
||||
pr.errors, 1, Location(Position(5, 40), Position(5, 48)), "Expected 'function' declaration after attribute, but got '1' intead");
|
||||
pr.errors, 1, Location(Position(5, 40), Position(5, 48)), "Expected 'function' declaration after attribute, but got '1' instead");
|
||||
}
|
||||
|
||||
TEST_CASE_FIXTURE(Fixture, "parse_attribute_on_function_type_declaration")
|
||||
@ -3493,7 +3493,7 @@ TEST_CASE_FIXTURE(Fixture, "dont_parse_attributes_on_non_function_type_declarati
|
||||
opts);
|
||||
|
||||
checkFirstErrorForAttributes(
|
||||
pr1.errors, 1, Location(Position(1, 17), Position(1, 20)), "Expected a function type declaration after attribute, but got 'foo' intead");
|
||||
pr1.errors, 1, Location(Position(1, 17), Position(1, 20)), "Expected a function type declaration after attribute, but got 'foo' instead");
|
||||
|
||||
ParseResult pr2 = tryParse(R"(
|
||||
@checked declare class Foo
|
||||
@ -3503,7 +3503,7 @@ end)",
|
||||
opts);
|
||||
|
||||
checkFirstErrorForAttributes(
|
||||
pr2.errors, 1, Location(Position(1, 17), Position(1, 22)), "Expected a function type declaration after attribute, but got 'class' intead");
|
||||
pr2.errors, 1, Location(Position(1, 17), Position(1, 22)), "Expected a function type declaration after attribute, but got 'class' instead");
|
||||
|
||||
ParseResult pr3 = tryParse(R"(
|
||||
declare bit32: {
|
||||
|
Loading…
Reference in New Issue
Block a user