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

Inline lambda parsed incorrectly #204

Open
Scony opened this issue Mar 3, 2023 · 2 comments
Open

Inline lambda parsed incorrectly #204

Scony opened this issue Mar 3, 2023 · 2 comments
Labels
bug Something isn't working parser
Milestone

Comments

@Scony
Copy link
Owner

Scony commented Mar 3, 2023

var x = func(y): return y == 1 if true else func(y): return y == 2
@Scony Scony added bug Something isn't working parser labels Mar 3, 2023
@Scony Scony added this to the 4.1 milestone Mar 23, 2023
@Scony Scony modified the milestones: 4.1, 4.x Nov 5, 2023
@3ter
Copy link

3ter commented May 18, 2024

In my case it throws an exception. Could it give a warning instead? This had the great advantage to not block the other parts (and scripts) from being formatted.

Example (where the last line is the culprit):

extends Node2D

var bubble_scene = preload("res://environment/bubble.tscn")


func _ready() -> void:
	spawn_bubble()


func spawn_bubble() -> void:
	var bubble = bubble_scene.instantiate() as Bubble
	add_child(bubble)
	bubble.tree_exited.connect(func(): if bubble.is_queued_for_deletion(): spawn_bubble())

EDIT: I didn't see the workaround in #191 (comment).
EDIT2: But I can't figure out how to do it in this case.

@Scony
Copy link
Owner Author

Scony commented May 21, 2024

In my case it throws an exception. Could it give a warning instead? This had the great advantage to not block the other parts (and scripts) from being formatted.

Example (where the last line is the culprit):

extends Node2D

var bubble_scene = preload("res://environment/bubble.tscn")


func _ready() -> void:
	spawn_bubble()


func spawn_bubble() -> void:
	var bubble = bubble_scene.instantiate() as Bubble
	add_child(bubble)
	bubble.tree_exited.connect(func(): if bubble.is_queued_for_deletion(): spawn_bubble())

EDIT: I didn't see the workaround in #191 (comment). EDIT2: But I can't figure out how to do it in this case.

Last time I've checked, Godot had no support for inline if in lambda so the above code would be invalid. I'll revisit that and potentially add support for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser
Projects
Status: No status
Development

No branches or pull requests

2 participants