Merge pull request #78494 from kinami-imai/SSDinaTvuI8geW91IGFsbAo=

Fix lambda parsing continuing on subsequent lines
This commit is contained in:
Rémi Verschelde 2023-06-21 13:52:42 +02:00 committed by GitHub
commit a2ce7a8f88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 93 additions and 1 deletions

View File

@ -2231,7 +2231,7 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_precedence(Precedence p_pr
ExpressionNode *previous_operand = (this->*prefix_rule)(nullptr, p_can_assign);
while (p_precedence <= get_rule(current.type)->precedence) {
if (previous_operand == nullptr || (p_stop_on_assign && current.type == GDScriptTokenizer::Token::EQUAL) || (previous_operand->type == Node::LAMBDA && lambda_ended)) {
if (previous_operand == nullptr || (p_stop_on_assign && current.type == GDScriptTokenizer::Token::EQUAL) || lambda_ended) {
return previous_operand;
}
// Also switch multiline mode on here for infix operators.

View File

@ -0,0 +1,6 @@
# https://github.com/godotengine/godot/issues/73273
func not_called():
var v
v=func(): v=1
in v

View File

@ -0,0 +1,2 @@
GDTEST_PARSER_ERROR
Expected statement, found "in" instead.

View File

@ -0,0 +1,59 @@
# https://github.com/godotengine/godot/issues/73273
func other(callable : Callable):
callable.call()
func four_parameters(_a, callable : Callable, b=func(): print(10)):
callable.call()
b.call()
func test():
var v
v=func():v=1
if true: v=1
print(v)
print()
v=func(): print(2) if false else print(3)
@warning_ignore("unsafe_cast")
(v as Callable).call()
print()
v=func():
print(4)
print(5)
@warning_ignore("unsafe_cast")
if true: (v as Callable).call()
print()
other(v)
print()
other(func(): print(6))
print()
other(func():
print(7)
print(8)
)
print()
four_parameters(1,func():print(9))
four_parameters(1,func():print(9), func(): print(11))
four_parameters(1,func():
print(12)
print(13)
, func(): print(11))
print()
from_ticket()
func from_ticket():
var _v
if true: _v = (func(): test())
if true: _v = (func(): test())
if true: _v = (func(): test())
if true: _v = func(): test()
if true: _v = func(): test()
print(14)

View File

@ -0,0 +1,25 @@
GDTEST_OK
1
3
4
5
4
5
6
7
8
9
10
9
11
12
13
11
14