[erlang-questions] Strange matching behavior
Lukas Larsson
lukas@REDACTED
Thu Sep 5 09:59:40 CEST 2019
Hello,
On Thu, Sep 5, 2019 at 9:39 AM block.rxckin.beats@REDACTED <
block.rxckin.beats@REDACTED> 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
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190905/99cb5b29/attachment.htm>
More information about the erlang-questions
mailing list