Repository: godot
Issue: Crash while calling anonymous functions that have been passed as function arguments 
Labels: bug,topic:gdscript,crash

### Godot version

v4.2.dev3.official [013e8e3af]

### System information

Godot v4.2.dev3 - Ubuntu 22.04.2 LTS 22.04 - Wayland - Vulkan (Forward+) - integrated Intel(R) Xe Graphics (TGL GT2) () - 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz (8 Threads)

### Issue description

I have a UI component who's `turn_on_focus` function accepts a couple `Callable` arguments to later call when elements are focused and selected. When invoking this function, I was passing in these `Callable` args as anonymous functions. This has been working fine in all versions of 4.x up until v4.2.dev3.official. I got it to stop crashing by moving the anonymous functions to declared functions on the call site's script.

See the following diff:
```
+++ b/states/select_action/target_state.gd
@@ -37,14 +37,8 @@ func enter(params = null):
        if action_data.target_mode & Action.TargetModes.ENEMY and not controller.game_data.alive_enemies.is_empty():
                controller.battle_container.turn_on_focus(
                        controller.game_data.alive_enemies.front() if action_data.preferred_target == Action.TargetModes.ENEMY else null,
-                       func(actor: EnemyActor):
-                               send_trigger(TargetsSelectedTrigger.new(self, [actor])),
-                       func(actor: EnemyActor):
-                               controller.sub_context_container.open({
-                                       'title': action_data.name,
-                                       'body': actor.enemy.name,
-                                       'back_pressed': send_trigger.bind(_cancel_trigger)
-                               })
+                       _on_enemy_container_selected,
+                       _on_enemy_container_hovered.bind(action_data)
                )
 
        if action_data.target_mode & Action.TargetModes.PLAYER:
@@ -64,6 +58,18 @@ func enter(params = null):
 
        super.enter()
 
+func _on_enemy_container_selected(actor: EnemyActor):
+       send_trigger(TargetsSelectedTrigger.new(self, [actor]))
+
+
+func _on_enemy_container_hovered(actor: EnemyActor, action_data):
+       controller.sub_context_container.open({
+               'title': action_data.name,
+               'body': actor.enemy.name,
+               'back_pressed': send_trigger.bind(_cancel_trigger)
+       })
+
+
```

And crash log:
```
================================================================
handle_crash: Program crashed with signal 11
Engine version: Godot Engine v4.2.dev3.official (013e8e3afb982d4b230f0039b6dc248b48794ab9)
Dumping the backtrace. Please include this when reporting the bug to the project developer.
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7fbd9c042520] (??:0)
[2] godot() [0x12ddc59] (??:0)
[3] godot() [0x11ab4b8] (??:0)
[4] godot() [0x484f09b] (??:0)
[5] godot() [0x4627bd4] (??:0)
[6] godot() [0x4627eb2] (??:0)
[7] godot() [0x48ae2b1] (??:0)
[8] godot() [0x2e11ece] (??:0)
[9] godot() [0x2e1298d] (??:0)
[10] godot() [0x2d9ef34] (??:0)
[11] godot() [0x2d9f8e6] (??:0)
[12] godot() [0x2dca465] (??:0)
[13] godot() [0xecdaf0] (??:0)
[14] godot() [0x4615c03] (??:0)
[15] godot() [0x4616a9e] (??:0)
[16] godot() [0xece19f] (??:0)
[17] godot() [0xe5e323] (??:0)
[18] /lib/x86_64-linux-gnu/libc.so.6(+0x29d90) [0x7fbd9c029d90] (??:0)
[19] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x80) [0x7fbd9c029e40] (??:0)
[20] godot() [0xe8f8ee] (??:0)
-- END OF BACKTRACE --
================================================================
```

### Steps to reproduce

I've tried to reproduce this in several ways, but can't quite get it to crash.

### Minimal reproduction project

As said above, I can't recreate the crash in an isolated way. Happy to send a contributor my project for testing.