Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heisen-variables (2) #6516

Closed
ilya-klyuchnikov opened this issue Nov 25, 2022 · 1 comment · Fixed by #6415
Closed

Heisen-variables (2) #6516

ilya-klyuchnikov opened this issue Nov 25, 2022 · 1 comment · Fixed by #6415
Assignees
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM
Milestone

Comments

@ilya-klyuchnikov
Copy link
Contributor

ilya-klyuchnikov commented Nov 25, 2022

(A continuation of #6141)

Describe the bug
Scoping of variables (and whether a variable is already bound or not) is not stable

To Reproduce

-module(scopes).
-compile([export_all, nowarn_export_all]).

scope1() ->
  {
    (X = 4),
    (X = 3)
  }.

scope2() ->
  {
    X = 4,
    (_ = (X = 3))
  }.
$ erlc scopes.erl
scopes.erl:7:6: Warning: no clause will ever match
%    7|     (X = 3)
%     |      ^

scopes.erl:7:6: Warning: this clause cannot match because its guard evaluates to 'false'
%    7|     (X = 3)
%     |      ^

$ erl 
1> scopes:scope1().
** exception error: no match of right hand side value 3
     in function  scopes:scope1/0 (scopes.erl, line 7)
2> scopes:scope2().
{4,3}

Expected behavior
The same behavior for scope1 and scope2. It seems that X is scoped differently under the hood in the 2 functions.

Affected versions
25.1

@ilya-klyuchnikov ilya-klyuchnikov added the bug Issue is reported as a bug label Nov 25, 2022
@bjorng bjorng self-assigned this Nov 26, 2022
@IngelaAndin IngelaAndin added the team:VM Assigned to OTP team VM label Nov 28, 2022
@bjorng bjorng linked a pull request Dec 5, 2022 that will close this issue
@bjorng bjorng added this to the OTP-26.0 milestone Dec 5, 2022
@bjorng
Copy link
Contributor

bjorng commented Dec 5, 2022

It turns out that this bug is fixed in #6415. We don't plan to fix it in OTP 25.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants