[erlang-questions] [Bug] io:setopts and expand_fun option
Gunilla Arendt
gunilla@REDACTED
Thu Mar 1 15:10:32 CET 2007
Ok, I've made a note about this. Thanks for the bug report.
Regards,
Gunilla, Erlang/OTP team
igwan wrote:
> Hello,
>
> I encountered a problem while playing with io:setopts trying to set the
> expand_fun option :
>
> 5> Completion = fun("") -> {yes, "start", ["start", "stop"]};
> 5> (_) -> {no, "", ["start", "stop"]} end.
> #Fun<erl_eval.6.56006484>
>
> 6> io:setopts([{expand_fun, Completion}]).
> {error,badarg}
>
> 7> io:setopts([binary]).
> ok
>
> 8> io:setopts([binary, {expand_fun, Completion}]).
> ok
>
> The problem is that setopts doesn't accept the 'expand_fun' option
> alone, it has to be provided along with either 'binary' or 'list' options.
> This is not stated in the documentation.
> The faulty code seems to be located in kernel/group.erl :
>
> %% setopts
> setopts(Opts0,_Drv, Buf) ->
> Opts = proplists:substitute_negations([{list,binary}], Opts0),
> put(expand_fun, proplists:get_value(expand_fun, Opts, get(expand_fun))),
> case proplists:get_value(binary, Opts) of
> true ->
> put(read_mode,binary),
> {ok,ok,Buf};
> false ->
> put(read_mode,list),
> {ok,ok,Buf};
> _ ->
> {error,{error,badarg},Buf}
> end.
>
> expand_fun is put in the process dictionary even if we get a {error,
> badarg} in response. I think it is not the intended behaviour. At least,
> it doesn't meet my expectation of "least astonishment" :)
>
> igwan
More information about the erlang-questions
mailing list