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

Godot 4 StringName not found in Array #68918

Closed
mrimvo opened this issue Nov 20, 2022 · 2 comments · Fixed by #68747
Closed

Godot 4 StringName not found in Array #68918

mrimvo opened this issue Nov 20, 2022 · 2 comments · Fixed by #68747

Comments

@mrimvo
Copy link

mrimvo commented Nov 20, 2022

Godot version

4.0 Beta 4

System information

Ubuntu 20.04

Issue description

StringName objects won't be found in Arrays (but it does work for Dictionaries):

if StringName("test") == "test":
	print("works")

if StringName("test") == in {test=true}:
	print("works")

# BUG
if StringName("test") in ["test"]:
	print("doesn't work")

# BUG
if node.name in ["A", "B"]:
	print("never printed, even is node is named A or B")

Steps to reproduce

Write and run the simple script I presented above.

Minimal reproduction project

See above.

@mrimvo mrimvo changed the title Godot 4 StringName not working with "in" operator Godot 4 StringName not found in Array Nov 20, 2022
@Chaosus Chaosus added this to the 4.0 milestone Nov 20, 2022
@Chaosus Chaosus moved this to To Assess in 4.x Priority Issues Nov 20, 2022
@Chaosus Chaosus moved this from To Assess to Todo in 4.x Priority Issues Nov 20, 2022
@souplamp
Copy link
Contributor

souplamp commented Nov 20, 2022

Related PR: #68747
Related Issue: #63965

@Mickeon
Copy link
Contributor

Mickeon commented Nov 21, 2022

A bit loosely related to godotengine/godot-proposals#5818 (comment) (see comment)

Unfortunately this is as much of a bug as an int and a float in an Array being two completely different Variant types. Same goes for Vector2 and Vector2i, and so on. If finding Variants in Arrays were to be loose, it'd be much, much slower.

One solution would be to at least make it opt-in. Maybe an optional parameter in Array.has()?

Don't worry I hate StringNames' practical implementation too

Repository owner moved this from Todo to Done in 4.x Priority Issues Dec 9, 2022
Repository owner moved this from Todo to Done in GDScript Stabilization Tasks Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants