You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using String::pad_zeros on a string containing digits with greater length than the argument digits raises the error Parameter count should be a positive number. of String::repeat, because it is called with a negative parameter.
(Actually this error is not 100% correct, it should be non-negative)
Example: "2023".pad_zeros(2) begin == 0 end == 4 zeros_to_add == 2 - (4 - 0) == -2
=> s.insert(0, String("0").repeat(-2)) is called => Error.
I don't know why this was changed, but I think ensuring that zeros_to_add > 0 should be ensured internally and not by the user. If this condition is not fullfilled the string should be returned unchanged as in the 4.0 implementation.
Steps to reproduce
Try my above mentioned example in 4.0 and 4.1
Minimal reproduction project
Not necessary.
The text was updated successfully, but these errors were encountered:
raises the error Parameter count should be a positive number. of String::repeat, because it is called with a negative parameter.
(Actually this error is not 100% correct, it should be non-negative)
Godot version
v4.1.stable.official [9704596]
System information
Windows 11
Issue description
Using
String::pad_zeros
on a string containing digits with greater length than the argumentdigits
raises the errorParameter count should be a positive number.
ofString::repeat
, because it is called with a negative parameter.(Actually this error is not 100% correct, it should be non-negative)
4.0 Code:
godot/core/string/ustring.cpp
Lines 4127 to 4155 in c8e0bd5
Example:
"2023".pad_zeros(2)
begin == 0
end == 4
end - begin < p_digits == false
=> No "0" is inserted, the string is returned unchanged.4.1 Code:
godot/core/string/ustring.cpp
Lines 4266 to 4290 in ce5c615
Example:
"2023".pad_zeros(2)
begin == 0
end == 4
zeros_to_add == 2 - (4 - 0) == -2
=>
s.insert(0, String("0").repeat(-2))
is called => Error.I don't know why this was changed, but I think ensuring that
zeros_to_add > 0
should be ensured internally and not by the user. If this condition is not fullfilled the string should be returned unchanged as in the 4.0 implementation.Steps to reproduce
Try my above mentioned example in 4.0 and 4.1
Minimal reproduction project
Not necessary.
The text was updated successfully, but these errors were encountered: