io:format/1+2 in OTP 21 doesn't take iodat() anymore

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

io:format/1+2 in OTP 21 doesn't take iodat() anymore

Adam Lindberg-7
Hi,

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"]).
    foobarok
    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?

Cheers,
Adam


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: io:format/1+2 in OTP 21 doesn't take iodat() anymore

Hans Bolinder-2
[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"]).
>     foobarok
>     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.

Best regards,

Hans Bolinder, Erlang/OTP team, Ericsson


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions