[erlang-questions] Strange matching behavior

block.rxckin.beats <>
Thu Sep 5 10:31:45 CEST 2019


Thanks a lot Lukas !

Jxck

2019年9月5日(木) 17:28 Lukas Larsson <>:

>
>
> On Thu, Sep 5, 2019 at 10:06 AM  <
> > wrote:
>
>> Hi Lukas
>>
>> Updating 10.4.4 works fine for me thanks.
>>
>
> 10.4.4 is the run-time version, not the compiler version. Though I get why
> you are confused as that is what is printed when you start an erlang shell.
>
>
>> Can I see the bug ticket for this behavior ?
>>
>
> I'm not sure which compiler fix it was that fixed this problem, but you
> can see what was fixed in each patch here:
> http://blog.erlang.org/cd/docs/maint-22/lib/compiler-7.4.4/doc/html/notes.html.
> My guess would be that it is OTP-15838 that fixed the problem that you had.
>
>
>>
>> Jxck
>>
>>
>> 2019年9月5日(木) 16:59 Lukas Larsson <>:
>>
>>> Hello,
>>>
>>> On Thu, Sep 5, 2019 at 9:39 AM  <
>>> > wrote:
>>>
>>>> I found strange behavior, see code below.
>>>>
>>>> why last match doesn't works ?
>>>>
>>>
>>> It is a bug in the compiler in OTP-22 that has been fixed. If you
>>> upgrade to the latest OTP-22 patched version it works as it should.
>>>
>>> Lukas
>>>
>>>
>>>>
>>>>
>>>> ```main.erl
>>>> #!/usr/bin/env escript
>>>> -module(main).
>>>>
>>>> -mode(compile).
>>>> -compile(export_all).
>>>>
>>>> xy() ->
>>>>     #{ 160506610  => x, 3960650446 => y }.
>>>>
>>>> x() ->
>>>>     #{ 160506610  => x }.
>>>>
>>>> y() ->
>>>>     #{ 3960650446 => y }.
>>>>
>>>> xy2() ->
>>>>     #{ 888888888  => x, 9999999999 => y }.
>>>>
>>>> main(_) ->
>>>>     #{ 160506610  := x } = xy(), % ok
>>>>     #{ 3960650446 := y } = xy(), % ok
>>>>
>>>>     #{ 160506610  := x } = x(), % ok
>>>>     #{ 3960650446 := y } = y(), % ok
>>>>
>>>>
>>>>     #{ 888888888  := x,
>>>>        9999999999 := y
>>>>      } = xy2(), % ok
>>>>
>>>>
>>>>     #{ 160506610  := x,
>>>>        3960650446 := y
>>>>      } = xy(), % no match of right hand side value, WHY ??
>>>>
>>>>     ok.
>>>> ```
>>>>
>>>> Erlang: Erlang/OTP 22 [erts-10.4] [source] [64-bit] [smp:8:8]
>>>> [ds:8:8:10] [async-threads:1] [hipe]
>>>> OS: Ubuntu 19.04 disco
>>>> _______________________________________________
>>>> erlang-questions mailing list
>>>> 
>>>> http://erlang.org/mailman/listinfo/erlang-questions
>>>>
>>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190905/93592922/attachment.htm>


More information about the erlang-questions mailing list