mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibCpp: Allow 'const' after a function's signature
This is too lax for functions that aren't class members, but let's allow that anyway.
This commit is contained in:
parent
3319114127
commit
b3cbe14569
Notes:
sideshowbarker
2024-07-18 07:36:25 +09:00
Author: https://github.com/alimpfard
Commit: b3cbe14569
Pull-request: https://github.com/SerenityOS/serenity/pull/9156
Reviewed-by: https://github.com/itamar8910 ✅
1 changed files with 8 additions and 0 deletions
|
@ -132,6 +132,11 @@ NonnullRefPtr<FunctionDeclaration> Parser::parse_function_declaration(ASTNode& p
|
|||
|
||||
consume(Token::Type::RightParen);
|
||||
|
||||
if (match_keyword("const")) {
|
||||
consume();
|
||||
// FIXME: Note that this function is supposed to be a class member, and `this` has to be const, somehow.
|
||||
}
|
||||
|
||||
RefPtr<FunctionDefinition> body;
|
||||
Position func_end {};
|
||||
if (peek(Token::Type::LeftCurly).has_value()) {
|
||||
|
@ -739,6 +744,9 @@ bool Parser::match_function_declaration()
|
|||
|
||||
while (consume().type() != Token::Type::RightParen && !eof()) { };
|
||||
|
||||
if (match_keyword("const"))
|
||||
consume();
|
||||
|
||||
if (peek(Token::Type::Semicolon).has_value() || peek(Token::Type::LeftCurly).has_value())
|
||||
return true;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue