Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix misspelling in parser.cpp #1330

Merged
merged 3 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Ast/src/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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());
}
}

Expand Down
22 changes: 11 additions & 11 deletions tests/Parser.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -3371,15 +3371,15 @@ 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"(
@checked
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
Expand All @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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
Expand All @@ -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: {
Expand Down
Loading