Strange matching behavior

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

Strange matching behavior

block.rxckin.beats@gmail.com
I found strange behavior, see code below.

why last match doesn't works ?


```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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Strange matching behavior

Lukas Larsson-8
Hello,

On Thu, Sep 5, 2019 at 9:39 AM [hidden email] <[hidden email]> 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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Strange matching behavior

block.rxckin.beats@gmail.com
Hi Lukas

Updating 10.4.4 works fine for me thanks.
Can I see the bug ticket for this behavior ?

Jxck


2019年9月5日(木) 16:59 Lukas Larsson <[hidden email]>:
Hello,

On Thu, Sep 5, 2019 at 9:39 AM [hidden email] <[hidden email]> 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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Strange matching behavior

Lukas Larsson-8


On Thu, Sep 5, 2019 at 10:06 AM [hidden email] <[hidden email]> 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 <[hidden email]>:
Hello,

On Thu, Sep 5, 2019 at 9:39 AM [hidden email] <[hidden email]> 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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Strange matching behavior

block.rxckin.beats@gmail.com
Thanks a lot Lukas !

Jxck

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


On Thu, Sep 5, 2019 at 10:06 AM [hidden email] <[hidden email]> 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 <[hidden email]>:
Hello,

On Thu, Sep 5, 2019 at 9:39 AM [hidden email] <[hidden email]> 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
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

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