Re: io:format/1+2 in OTP 21 doesn't take iodat() anymore
[Thu Jul 12 10:24:48 CEST 2018 Adam Lindberg wrote:]
> Haven't found any information anywhere in the changelogs about this,
> but there seems to be a regression in the way io:format/1+2 works.
> It used to be possible to call it with a mixed IO list of binaries and
> strings (iodata()), but this is no longer possible:
> 14> io:format(["foo", "bar"]).
> 15> io:format([<<"foo">>, "bar"]).
> ** exception error: bad argument
> in function io:format/3
> called as io:format(<0.63.0>,[<<"foo">>,"bar"],)
> It seems it was never documented, as the format was always 'atom() |
> string() | binary()', but in practice 'iodata()' was allowed. Is this
> change intentional or is it a bug?
The change is a consequence of some refactoring (OTP-14983, option
'chars_limit'). Thanks for pointing it out; I didn't notice the change.
We'll make your example work in Erlang/OTP 21.1. See commit 2d04d2b.
And we'll consider introducing better runtime checking of the Format
argument in Erlang/OTP 22.0. The reason is that control sequences are
ignored if Format is, for instance, a list of binaries.