Skip to content

Instantly share code, notes, and snippets.

@pguillory
Last active June 14, 2016 16:51
Show Gist options
  • Select an option

  • Save pguillory/d7c090e226c8aed619af6a4d1963c69c to your computer and use it in GitHub Desktop.

Select an option

Save pguillory/d7c090e226c8aed619af6a4d1963c69c to your computer and use it in GitHub Desktop.

Revisions

  1. pguillory revised this gist Jun 14, 2016. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion output.txt
    Original file line number Diff line number Diff line change
    @@ -9,4 +9,6 @@ case(:condition) do
    nil
    _ ->
    :ok
    end
    end

    # cannot invoke remote function Enum.member?/2 inside guard
  2. pguillory revised this gist Jun 14, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion test.ex
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,6 @@ block
    |> IO.puts

    block
    |> Macro.prewalk(&Macro.expand_once(&1, __ENV__))
    |> Macro.prewalk(&Macro.expand(&1, __ENV__))
    |> Macro.to_string
    |> IO.puts
  3. pguillory created this gist Jun 14, 2016.
    12 changes: 12 additions & 0 deletions output.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    case(:condition) do
    x when x in [false, nil] ->
    nil
    _ ->
    :ok
    end
    case(:condition) do
    x when Enum.member?([false, nil], x) ->
    nil
    _ ->
    :ok
    end
    13 changes: 13 additions & 0 deletions test.ex
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    block = quote do
    if :condition do :ok end
    end

    block
    |> Macro.expand_once(__ENV__)
    |> Macro.to_string
    |> IO.puts

    block
    |> Macro.prewalk(&Macro.expand_once(&1, __ENV__))
    |> Macro.to_string
    |> IO.puts