-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugIssue is reported as a bugIssue is reported as a bugteam:VMAssigned to OTP team VMAssigned to OTP team VM
Description
Describe the bug
In some specific cases pattern matching doesn't do what it's supposed to - instead it mutates variables.
To Reproduce
Given the following snippet:
-module(test).
-export([test/0]).
test() ->
Zero = 0,
One = 1,
Result = One = Zero,
io:format("~p ~p~n", [Zero, One]),
Result.Compiling the test module and running test:test() from the shell produces:
1> test:test().
0 0
0Expected behavior
The code should crash with match error, and variables should remain immutable.
Affected versions
Tested with the latest maint-25 and maint-24 branches. This correctly fails on current master, even emitting a warning during compilation with erlc.
Additional context
Originally discovered by @jcpetruzza
robertoaloiTD5, danilagamma, jhogberg, RobinMorisset, robertoaloi and 8 more
Metadata
Metadata
Assignees
Labels
bugIssue is reported as a bugIssue is reported as a bugteam:VMAssigned to OTP team VMAssigned to OTP team VM