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
Describe the bug
Modifiers that make no sense for a given control character (like the modifier k (map key order ordered) for the control character b (integer)) are silently ignored if the formatting is successful. However, if there is an error, the reported error reason is "format string invalid (invalid modifier/control combination ~kb)". And while it is true that the modifier makes no sense for the given control character, it is arguably not an error (in the sense that by itself it works), and it is usually not the reason for the error at hand.
The reason is that erl_stdlib_errors relies on erl_lint:check_format_string for io error reporting. While it makes sense for a linter to detect invalid modifier/control character combinations, it poses a problem for error cause detection when the questionable combination is not actually an error.
Related, the value for the K modifier (expected to be either undefined, ordered, reversed or a fun/2) is allowed to be anything unless the value to be formatted is a non-empty map. This should actually be an error.
Describe the bug
Modifiers that make no sense for a given control character (like the modifier
k
(map key orderordered
) for the control characterb
(integer)) are silently ignored if the formatting is successful. However, if there is an error, the reported error reason is "format string invalid (invalid modifier/control combination ~kb)". And while it is true that the modifier makes no sense for the given control character, it is arguably not an error (in the sense that by itself it works), and it is usually not the reason for the error at hand.The reason is that
erl_stdlib_errors
relies onerl_lint:check_format_string
forio
error reporting. While it makes sense for a linter to detect invalid modifier/control character combinations, it poses a problem for error cause detection when the questionable combination is not actually an error.Related, the value for the
K
modifier (expected to be eitherundefined
,ordered
,reversed
or afun/2
) is allowed to be anything unless the value to be formatted is a non-empty map. This should actually be an error.To Reproduce
1>
, the format string is accepted even though thek
modifier is invalid for theb
control character.2>
, the real reason for the error is that the atomx
can not be formatted with theb
control character3>
, the real reason for the error is that the number of values does not match the number of format sequences4>
, the real reason for the error is the invalid control character~q
Regarding the
K
modifier:5>
,foo
is incorrectly allowed asK
-value when the value to be formatted is not a map6>
,foo
is incorrectly even allowed asK
-value even though the value to be formatted is a map7>
, the incorrectK
-value is detected, but no error message is createdExpected behavior
2>
,3>
and4>
)K
-values are detected (cases5>
and6>
), at least when the value to be formatted is a map even if empty (case6>
)K
-value is invalid, an appropriate error message should be displayed.Affected versions
OTP 27.0 and earlier
The text was updated successfully, but these errors were encountered: