Ask questionsChannel test fails to compile on Elixir 1.9: "cannot invoke remote function String.Chars.to_string/1 inside a match"



  • For general discussions and support, use Stack Overflow or the Elixir Forum
  • For proposing and discussing new features, start a thread on the Phoenix Core mailing list
  • For bugs, do a quick search and make sure the bug has not yet been reported
  • Ensure that this issue is related to the Phoenix library and not one of the dependencies listed in mix.exs (Ecto, Plug, etc.)
  • All checked? Be nice and have fun! -->

Started working again on a project that I last touched on Elixir 1.8. Now on 1.9, when I try to run mix test my channel tests won't compile & run any more:

== Compilation error in file test/.../channels/mytest.exs ==
** (CompileError) test/.../channels/mytest.exs:17: cannot invoke remote function String.Chars.to_string/1 inside a match
    (elixir) src/elixir_bitstring.erl:150: :elixir_bitstring.do_expand_expr/4
    (elixir) src/elixir_bitstring.erl:27: :elixir_bitstring.expand/8
    (elixir) src/elixir_bitstring.erl:10: :elixir_bitstring.expand/4
    (stdlib) lists.erl:1354: :lists.mapfoldl/3
    (stdlib) lists.erl:1354: :lists.mapfoldl/3
    (stdlib) lists.erl:1355: :lists.mapfoldl/3
    (stdlib) lists.erl:1354: :lists.mapfoldl/3
    (stdlib) lists.erl:1355: :lists.mapfoldl/3
    (stdlib) lists.erl:1354: :lists.mapfoldl/3
    (stdlib) lists.erl:1355: :lists.mapfoldl/3
    (stdlib) lists.erl:1354: :lists.mapfoldl/3
    (ex_unit) expanding macro: ExUnit.Assertions.assert_receive/2

Test looks roughly like this:

test "correctly tracking note edit start and end", %{socket: socket} do
    push(socket, "edit_start", %{"note" => 1})

    assert_push "presence_diff", %{
      joins: %{
        "#{@uid}" => %{metas: [%{edits: %{1 => %{}}}]}

The offending line #17 is the one with the assert_push. I don't have any special setup going.

What's going wrong here?


  • Elixir version (elixir -v):
Erlang/OTP 22 [erts-10.4.4] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe] [dtrace]

Elixir 1.9.0 (compiled with Erlang/OTP 22)
  • Phoenix version (mix deps): "phoenix": {:hex, :phoenix, "1.4.9", "746d098e10741c334d88143d3c94cab1756435f94387a63441792e66ec0ee974", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.8.1 or ~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm"},
  • NodeJS version (node -v): -
  • NPM version (npm -v): -
  • Operating system: macOS Mojave 10.14.5

Expected behavior

Test should compile and run.

Actual behavior

Test does not compile.


Answer questions seeekr

✗ elixir -v
Erlang/OTP 22 [erts-10.4.4] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]

Elixir 1.9.1 (compiled with Erlang/OTP 20)
Denis Andrejew seeekr Austria distributed systems & infrastructure
Github User Rank List