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

Sigil not working with assert macro in Elixir 1.14 #14

Open
emaiax opened this issue Sep 8, 2022 · 2 comments
Open

Sigil not working with assert macro in Elixir 1.14 #14

emaiax opened this issue Sep 8, 2022 · 2 comments

Comments

@emaiax
Copy link

emaiax commented Sep 8, 2022

Elixir 1.14.0
Erlang/OTP 24

The sigil seems to not be working with ExUnit's assert macro when used as an argument to a function.

To reproduce:

defmodule ShorterMapsTest do
  use ExUnit.Case

  import ShorterMaps

  test "broken" do
    input = %{"name" => "myname", "age" => 123}

    assert %{"input" => ^input} = ~m{input}
    assert %{"input" => input} == ~m{input}

    assert is_input?(input)
    assert is_input?(~m{input})
  end

  defp is_input?(~m{input}), do: true
  defp is_input?(_input), do: false
end

It gives the following error:

== Compilation error in file test/myapp/shorter_maps_test.exs ==
** (ArgumentError) interpolation is not supported with the ~m sigil
    (shorter_maps 2.2.5) expanding macro: ShorterMaps.sigil_m/2
    test/myapp/shorter_maps_test.exs:13: ShorterMapsTest."test broken"/1
    (elixir 1.14.0) expanding macro: Kernel.if/2
    test/myapp/shorter_maps_test.exs:13: ShorterMapsTest."test broken"/1
    (ex_unit 1.14.0) expanding macro: ExUnit.Assertions.assert/1
    test/myapp/shorter_maps_test.exs:13: ShorterMapsTest."test broken"/1

Line 13 is exactly assert is_input?(~m{input}).

This was working fine until Elixir 1.13.x, and now it's broken. I'm not sure where to start digging. :/

@emaiax
Copy link
Author

emaiax commented Sep 8, 2022

Perhaps it has some relation with #11

@meyercm
Copy link
Owner

meyercm commented Feb 9, 2023

Sorry to have missed when this arrived - this problem seems super annoying - I'll take a look and see what I can find.

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

No branches or pull requests

2 participants