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

Eliminate "mutable variables" #6877

Conversation

bjorng
Copy link
Contributor

@bjorng bjorng commented Feb 16, 2023

The compiler would generate incorrect code for the following type of expression:

Pattern = BoundVar1 = . . . = BoundVarN = Expression

An exception should be raised if any of the bound variables have different values than Expression. The compiler would generate code that would cause the bound variables to be bound to the value of Expression whether the value matched or not.

For example:

t() ->
    Zero = 0,
    One = 1,
    Result = One = Zero,
    {Result,One,Zero}.

There should be a badmatch exception, but instead, the t/0 function returned {0,0,0}.

Closes #6873

The compiler would generate incorrect code for the
following type of expression:

    Pattern = BoundVar1 = . . . = BoundVarN = Expression

An exception should be raised if any of the bound variables have
different values than `Expression`. The compiler would generate code
that would cause the bound variables to be bound to the value of
`Expression` whether the value matched or not.

For example:

    t() ->
        Zero = 0,
        One = 1,
        Result = One = Zero,
        {Result,One,Zero}.

There should be a `badmatch` exception, but instead, the `t/0`
function returned `{0,0,0}`.

Closes erlang#6873
@bjorng bjorng added team:VM Assigned to OTP team VM fix testing currently being tested, tag is used by OTP internal CI labels Feb 16, 2023
@bjorng bjorng requested a review from jhogberg February 16, 2023 17:17
@bjorng bjorng self-assigned this Feb 16, 2023
@bjorng bjorng linked an issue Feb 16, 2023 that may be closed by this pull request
@github-actions
Copy link
Contributor

github-actions bot commented Feb 16, 2023

CT Test Results

       2 files     253 suites   9m 18s ⏱️
   729 tests    727 ✔️ 2 💤 0
3 971 runs  3 969 ✔️ 2 💤 0

Results for commit bff8f7e.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@bjorng bjorng merged commit 753d90b into erlang:maint Feb 17, 2023
@bjorng bjorng deleted the bjorn/compiler/fix-mutable-variables/24/GH-6873/OTP-18470 branch June 9, 2023 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mutable variables - let 1 become 0
1 participant