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 an unsafe optimization of list matching #8189

Conversation

bjorng
Copy link
Contributor

@bjorng bjorng commented Feb 26, 2024

In rare circumstances, the compiler could do an unsafe rewrite of list matching operations. For example:

[PrevRow | _] = Rows,
[_ | PrevRowT] = PrevRow,
. . .

Provided that the type analysis pass had figured out that Rows is always a list of at least two elements, the compiler would essentially rewrite the code to:

[PrevRow | PrevRowT] = Rows,
. . .

Fixes #8187

In rare circumstances, the compiler could do an unsafe rewrite of
list matching operations. For example:

    [PrevRow | _] = Rows,
    [_ | PrevRowT] = PrevRow,
    . . .

Provided that the type analysis pass had figured out that `Rows` is
always a list of at least two elements, the compiler would essentially
rewrite the code to:

    [PrevRow | PrevRowT] = Rows,
    . . .

Fixes erlang#8187
@bjorng bjorng added team:VM Assigned to OTP team VM fix testing currently being tested, tag is used by OTP internal CI labels Feb 26, 2024
@bjorng bjorng requested a review from jhogberg February 26, 2024 06:57
@bjorng bjorng self-assigned this Feb 26, 2024
Copy link
Contributor

github-actions bot commented Feb 26, 2024

CT Test Results

    2 files    324 suites   10m 17s ⏱️
  807 tests   805 ✅ 2 💤 0 ❌
5 371 runs  5 369 ✅ 2 💤 0 ❌

Results for commit f441ac9.

♻️ 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 033cc1f into erlang:master Feb 27, 2024
17 checks passed
@bjorng bjorng deleted the bjorn/compiler/fix-unsafe-get_list/GH-8187/OTP-19003 branch March 1, 2024 12:37
@bjorng bjorng restored the bjorn/compiler/fix-unsafe-get_list/GH-8187/OTP-19003 branch March 1, 2024 12:40
@bjorng bjorng deleted the bjorn/compiler/fix-unsafe-get_list/GH-8187/OTP-19003 branch April 25, 2024 03:48
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.

Code behaves differently in the presence of erlang:display/1
2 participants