-
-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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
Inconsistent implicit conversion between types in debug and release builds when export hint doesn't match default initialization #39215
Comments
It should work if you remove the quotation marks. |
when you press play press play, the editor casting the variable speed to |
@JulianDH97 Thanks, I had already figured that out, just wanted to file it here as I think this is a bug. @ThakeeNathees I'll use static types more often now, it seems a good idea to catch those issues. |
Weird message. 2 operands for an unary operator? Otherwise there's no bug - your variable was typed dynamically so it was possible to assign anything to it. Export hint only limits what can be set via Inspector. |
Shouldn't the editor play action closely match the behaviour of the exported binary? |
In theory, yes. In practice, subtle bugs like these can appear as the exported binary doesn't include RTTI (run-time type information) to decrease its binary size. Not to mention many debugging checks are also disabled in release builds. |
We discussed this on chat with @vnen, the way we'd propose to fix this is:
export(int) var speed = "8" # Warning
export(int) var speed := "8" # Warning
export(int) var speed : String = "8" # Warning This doesn't need to raise a warning per se as it would behave correctly: export(int) var speed : int = "8" # No warning It's a bit silly in this case, but here's a case with the same issue and a more common use case: export(float) var speed : float = 8 # No warning Here a On the other hand these should still raise a warning, as here no coercion would happen and thus errors will ensue: export(float) var speed = 8 # Warning
export(float) var speed := 8 # Warning |
I realized I didn't comment on this, so here's my thoughts on this.
I do agree not coercing is the way to go, but doing so will reintroduce #27575 (which was fixed by adding this coercion). I couldn't figure out yet another for that. That's the reason I haven't done a PR for this yet.
We could add the warning but keep the coercion for now, since the above bug is arguably worse than this one. At least until we can find a proper fix for that. The warning would tell that those values are coerced only in editor, not when exported. |
Fixed by #58686. |
Godot version:
3.2 Stable
Issue description:
This code doesn't lead to an editor warning (exporting int when value is String).
It does run in the editor when pressing play, but it does not work on export.
There it gives the error message: "Invalid operands 'String' and 'String' in operator '-(negation)'"
The text was updated successfully, but these errors were encountered: