Skip to content

assert fails on pattern matching with typed binary pattern matching #9926

@ityonemo

Description

@ityonemo

Environment

Erlang/OTP 22 [erts-10.7] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]
Elixir 1.10.2 (compiled with Erlang/OTP 21)

Linux Mint 19.2 ~ (Ubuntu Bionic)

Current behavior

code:

defmodule StringAssertTest do
  use ExUnit.Case

  test "passes" do
    input = "foobar"
    assert <<trap::binary-size(3)>> <> "bar" = input
    assert trap == "foo"
  end

  test "failsbad" do
    input = "foobar"
    assert <<trap::binary-size(3)>> <> "baz" = input
    assert trap == "foo"
  end

end
** (FunctionClauseError) no function clause matching in String.Unicode.length/1
    (elixir 1.10.2) lib/elixir/unicode/unicode.ex:266: String.Unicode.length({:<<>>, [line: 12], [{:"::", [line: 12], [{:trap, [line: 12], nil}, {:-, [line: 12], [{:binary, [line: 12], nil}, {:size, [line: 12], [3]}]}]}]})
    (ex_unit 1.10.2) lib/ex_unit/diff.ex:766: ExUnit.Diff.parse_string/1
    (ex_unit 1.10.2) lib/ex_unit/diff.ex:731: ExUnit.Diff.diff_string_concat/3
    (elixir 1.10.2) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
    (elixir 1.10.2) lib/task/supervised.ex:35: Task.Supervised.reply/5
    (stdlib 3.12) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Function: &ExUnit.Diff.compute/3
    Args: [{:<>, [expanded: {:<<>>, [], [{:"::", [], [{:<<>>, [line: 12], [{:"::", [line: 12], [{:trap, [line: 12], nil}, {:-, [line: 12], [{:binary, [line: 12], nil}, {:size, [line: 12], [3]}]}]}]}, {:binary, [], nil}]}, "baz"]}, line: 12], [{:<<>>, [line: 12], [{:"::", [line: 12], [{:trap, [line: 12], nil}, {:-, [line: 12], [{:binary, [line: 12], nil}, {:size, [line: 12], [3]}]}]}]}, "baz"]}, "foobar", {:match, []}]

this error stops the vm completely.

Expected behavior

Simple fail

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions