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

Recursive binary pattern matching + binary for comprehension => Internal consistency check failed #10309

Closed
jechol opened this issue Sep 8, 2020 · 2 comments

Comments

@jechol
Copy link

jechol commented Sep 8, 2020

Environment

  • Elixir & Erlang/OTP versions (elixir --version):
    Erlang/OTP 23 [erts-11.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]
    Elixir 1.10.4 (compiled with Erlang/OTP 23)
  • Operating system: macOS

Current behavior

When bin is pattern matched as binary twice and then used in binary for comprehension,
Internal consistency check failed

def encode_bin(<<bin::binary>> = bin) do
  for <<chunk::binary-size(5) <- bin>> do
    chunk
  end
end
== Compilation error in file lib/recursive_pattern.ex ==
** (CompileError) Elixir.RecursivePattern: function encode_bin/1+13:
  Internal consistency check failed - please report this bug.
  Instruction: {call_only,1,{f,17}}
  Error:       {bad_arg_type,{x,0},{t_bs_context,1,0,0},{t_bs_context,8,0,0}}:

    (stdlib 3.13) lists.erl:1338: :lists.foreach/2
    (elixir 1.10.4) src/elixir_erl_compiler.erl:12: anonymous fn/3 in :elixir_erl_compiler.spawn/2

I have uploaded simple project to reproduce this easily.
https://github.com/jechol/recursive_pattern

Expected behavior

Same code is working well with Elixir 1.10.4 + OTP 22.

@jechol jechol changed the title Recursive pattern matching => Internal consistency check failed Recursive binary pattern matching + binary for comprehension => Internal consistency check failed Sep 8, 2020
@jechol jechol changed the title Recursive binary pattern matching + binary for comprehension => Internal consistency check failed Recursive binary pattern matching + binary for comprehension => Internal consistency check failed Sep 8, 2020
@josevalim
Copy link
Member

@jechol thanks for the great report! Reported upstream here: https://bugs.erlang.org/browse/ERL-1340

@jhogberg
Copy link

We'll release a fix in OTP 23.1 next week. Thanks again for your report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants