ITADN

Cannot use defeffect with some guard clauses

#5Closedmfeckie 创建于 2024-07-30
bug
M
mfeckiecommented
This is a very nice library and I'm just adding it to a project where it's proving extremely helpful compared to other mocking approaches. I hit a little snag though. Given a function like this ```elixir @spec test_fn(atom(), atom()) :: any() defeffect test_fn(left, right) when left in [:a, :b] do nil end ``` or ```elixir @spec test_fn(atom(), atom()) :: any() defeffect test_fn(left, right) when is_atom(left) do nil end ``` It causes a macro compilation failure with ``` error: undefined variable "arg1" (context Snappy.ImageComparison.Runner) │ 324 │ defeffect test_fn(left, right) when left in [:a, :b] do │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ │ └─ lib/snappy/image_comparison/runner.ex:324: Snappy.ImageComparison.Runner.arg1/0 error: undefined variable "arg2" (context Snappy.ImageComparison.Runner) │ 324 │ defeffect test_fn(left, right) when left in [:a, :b] do │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` Would this be something that you'd expect to work?
关闭于 2024-08-03 4 条评论