godot-gdscript-toolkit icon indicating copy to clipboard operation
godot-gdscript-toolkit copied to clipboard

Inline lambda parsed incorrectly

Open Scony opened this issue 2 years ago • 4 comments

var x = func(y): return y == 1 if true else func(y): return y == 2

Scony avatar Mar 03 '23 22:03 Scony

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 https://github.com/Scony/godot-gdscript-toolkit/issues/191#issuecomment-2064904617. EDIT2: But I can't figure out how to do it in this case.

3ter avatar May 18 '24 19:05 3ter

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.

Scony avatar May 21 '24 20:05 Scony