godot: `match` statement performs strict type checking unlike `if`, causing it to fail unexpectedly when comparing String to StringName
Godot version
4.0 alpha5
System information
linux
Issue description
im trying to use “match” statement when an animation has finished. however it doesnt work anymore. print debug doesnt see the match of an animation name
an “if” statement does work however
Steps to reproduce
func _on_animation_player_animation_finished(anim_name):
if anim_name == "Fire":
isfiring = false
match anim_name:
"Fire":
isfiring = false
print_debug("no match, anim_name=", anim_name)`
Minimal reproduction project
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 15 (9 by maintainers)
That’s fine, and I’m glad you have a solution. This is now no longer about your individual issue. It’s about a philosophical design choice in the language that needs to be worked out for all Godot game devs. So far about 6 people have expressed a desire for reverting the change and no people or reasons for keeping the new behavior.
I agree, it seems unintuitive.
Godot 3.x didn’t have a StringName type exposed to GDScript, so everything was a String – including
anim_name
in your example.Yes 🙂