Capitalize INF, -INF, and NAN in serializing#100414
Conversation
5b15a8d to
0838d07
Compare
0838d07 to
88c4f06
Compare
88c4f06 to
22f548a
Compare
|
There's really a lot to unpack here, and it's hard to have a good overview. I'm not against changing the serialization to uppercase identifiers and specifically We should pick one convention and enforce it (and if we're changing it, then we do still need to support the previous convention as compatibility code - but that's only for compatibility's sake, not a design decision that we should support any possible variant the user may come up with). I would suggest focusing on fixing bugs in priority, and then assess the more "cosmetic" changes. If we can fix parsing |
|
I feel like this is a bit of a paradox, then. As you stated in #100395, the constants are supposed to be capitalized to match GDScript. But capitalizing the constants is a "cosmetic" change. So... it's non-cosmetic, yet cosmetic.
PR #100395 allows Expression to read
I did both at once since this way we only need to handle negative infinity as |
93011d8 to
cdcf39a
Compare
cdcf39a to
7a9c7cf
Compare
7a9c7cf to
0a35a04
Compare
In this PR, the relevant changes are done in core/variant/variant_parser.cpp. So this PR should in theory maintain compatibility already, not just for PackedScenes, but for other methods that convert strings into variants. |
48e4d52 to
94e91a0
Compare
89901fb to
ef47ab1
Compare
ef47ab1 to
bc894b4
Compare
Mickeon
left a comment
There was a problem hiding this comment.
I won't hold you at gunpoint for this but there's actually a few more places in the @GlobalScope.xml that directly refer to these values, and they would need to be changed as well.
5e4aafa to
49f0b1d
Compare
49f0b1d to
2195a32
Compare
2195a32 to
2c9132c
Compare
2c9132c to
9e3e0a8
Compare
322bb8a to
bf6d3cb
Compare
bf6d3cb to
cfb3d1a
Compare
225307f to
f167768
Compare
f167768 to
070607b
Compare
070607b to
b259888
Compare
841718b to
79a8567
Compare
acdb8b2 to
a9b4803
Compare
Zehir
left a comment
There was a problem hiding this comment.
Tested the PR and works as expected.
The value in JSON.from_native are now uppercase.
The value in the .tscn and in var_to_str are like before aka inf_neg for -INF
The tscn files does decode for both lowercase and upper case and -INF.
Looked at the code, seems OK for me.
Range.value. #81076inf,nanvalues to uppercase #53698As explained by bug report #88006, the editor inspector is unable to display non-finite values such as infinity and NaN. This is due to this check in Range (
range.cpp) added by #81076:If we remove this check, then non-finite values become allowed. They have to be typed as
INF,-INF, orNANlike GDScript, and then get displayed asinf,-inf, ornan:Inside of the
.tscnfile the values get serialized asinf,inf_neg, ornan:So, it's clear that simply removing this check is not enough. We need to fix these problems:
-infandinf_neg(less important, but we should still be consistent).Allowing the user to type both
infandINFis just generally a good idea, and stands on its own, so I put this into a separate PR here: #100395. This fixes the first point, since users can typeinflike they seeinf.However, I think there is value in fixing the other two points as well. Capitalizing the displayed and serialized text is pretty straightforward, it's just an arbitrary choice we make as engine developers, although we need to keep the code being able to read
infand such to keep reading old files (and if this is merged, we should backport a fix to older branches to allowINFetc to be read by older Godot versions).As for
inf_neg, the current reason for this is that VariantParser is not able to parse-INFas a single thing. It has this code in master which checks for-or a number as a start of a numeric literal:However, if you look closely at the code, we can see that it's needlessly checking for
'-'twice. A simple fix would be to rearrange this code slightly, so that it only needs to check for a leading'-'once:This way, we can handle reading
-INFor really any negated identifier (-INFwould be the only one at the moment, but I could imagine adding-PIor something, in any case making this code work for all cases has no downsides).If desired, I can undo the change inHowever, as for the rest of this PR, I think it's a good improvement to have the serialization and display ofrange.cpp, un-undoing #81076, leaving #88354 to be the PR changing the exposed behavior of Range.INF,-INF, andNANvalues match what users already expect from GDScript. Aside from capitalization, it's important that this PR fixes reading negated identifiers such as-infand-INF, so we can be consistent and avoidinf_neg/INF_NEG.