summaryrefslogtreecommitdiff
path: root/lib/elixir/test
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@dashbit.co>2023-03-20 13:21:16 +0100
committerJosé Valim <jose.valim@dashbit.co>2023-03-20 13:21:16 +0100
commit2c34551c6582fa1728b92fdfc5e4a544039faafc (patch)
treef46e833af5a0e8fb6512f576cf9232f6d37c10d2 /lib/elixir/test
parent96bab2465dc6ebd7c313bace0ccf4d25b0df29d5 (diff)
downloadelixir-2c34551c6582fa1728b92fdfc5e4a544039faafc.tar.gz
Consider operator precedence on guard blaming, closes #12479
Diffstat (limited to 'lib/elixir/test')
-rw-r--r--lib/elixir/test/elixir/exception_test.exs29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/elixir/test/elixir/exception_test.exs b/lib/elixir/test/elixir/exception_test.exs
index 67e1e39e3..8ab46e3cf 100644
--- a/lib/elixir/test/elixir/exception_test.exs
+++ b/lib/elixir/test/elixir/exception_test.exs
@@ -421,6 +421,35 @@ defmodule ExceptionTest do
assert Exception.blame(:exit, :function_clause, stack) == {:function_clause, stack}
end
+ test "handles operators precedence" do
+ import PathHelpers
+
+ write_beam(
+ defmodule OperatorPrecedence do
+ def test!(x, y) when x in [1, 2, 3] and y >= 4, do: :ok
+ end
+ )
+
+ :code.delete(OperatorPrecedence)
+ :code.purge(OperatorPrecedence)
+
+ assert blame_message(OperatorPrecedence, & &1.test!(1, 2)) =~ """
+ no function clause matching in ExceptionTest.OperatorPrecedence.test!/2
+
+ The following arguments were given to ExceptionTest.OperatorPrecedence.test!/2:
+
+ # 1
+ 1
+
+ # 2
+ 2
+
+ Attempted function clauses (showing 1 out of 1):
+
+ def test!(x, y) when (x === 1 or -x === 2- or -x === 3-) and -y >= 4-
+ """
+ end
+
test "reverts is_struct macro on guards for blaming" do
import PathHelpers