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

GDScript 2.0: When using named enums, accessing invalid members won't be caught while editing #60545

Closed
MuffinManKen opened this issue Apr 26, 2022 · 2 comments · Fixed by #69590

Comments

@MuffinManKen
Copy link
Contributor

MuffinManKen commented Apr 26, 2022

Godot version

v4.0.alpha6.official [e4f0fc5]

System information

Windows 10

Issue description

If you access an invalid member of a named enum, the editor won't catch the issue, but an error will be thrown at runtime.
If you do the same thing with an unnamed enum, the editor will flag it immediately.

I understand this is likely because named enums are a Dictionary, but it seems to me that it would be an improvement having named enums get flagged in the editor similar to unnamed enums.

Steps to reproduce

See code in repro section

Minimal reproduction project

enum GAME_STATE {WIN, LOSE}

var state1_good = GAME_STATE.WIN
var state1_bad = GAME_STATE.DRAW  #This will throw an error at runtime

enum {STATE_WIN, STATE_LOSE}

var state2_good = STATE_WIN
var state2_bad = STATE_DRAW #This will be flagged in the editor
@Calinou
Copy link
Member

Calinou commented Apr 26, 2022

Related to #59696.

@Calinou Calinou added this to the 4.0 milestone Apr 26, 2022
@Calinou Calinou changed the title GDScript 2.0 : When using Named Enums, accessing invalid members won't be caught while editing GDScript 2.0: When using named enums, accessing invalid members won't be caught while editing Apr 26, 2022
@anvilfolk
Copy link
Contributor

Added a fix for this one in #69590! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants