You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Erlang/OTP 21 [erts-10.2], Elixir 1.7.2 (compiled with Erlang/OTP 21)
Operating system: Ubuntu 16.04
Current behavior
When using location: :keep, "cannot match" warnings are generated with the file name where the macro is defined but line number where the macro is called.
# bug_test.exdefmoduleBugTestdodefmacrogenerate_function()doquotelocation: :keepdodefunquote(:test)()do# Line 4:okendendendend
# test.exstest"bug"dodefmoduleTestdorequireBugTestBugTest.generate_function# Line 113BugTest.generate_function# Line 114endend
Generates the warning
warning: this clause cannot match because a previous clause at line 113 always matches
lib/bug_test.ex:114
If the macro is defined without location: :keep, the warning is
warning: this clause cannot match because a previous clause at line 113 always matches
test/test.exs:114
Expected behavior
I'm not sure if this is a bug or my misunderstanding, but the first warning looks weird, since the lines 113 and 114 don't even exist in bug_test.ex.
I understand that it's tricky to show a proper warning message here because the issue comes from calling the macro twice, so we need to reference this. However, I think a clearer warning message would be something like:
warning: this clause cannot match because a previous clause at line 113 in test/text.exs always matches
lib/bug_test.ex:4
or simply
warning: this clause cannot match because a previous clause at line 113 always matches
lib/bug_test.ex:4
That way, if we had multiple functions being generated by the generate_function macro we could see which function cannot be matched.
The text was updated successfully, but these errors were encountered:
Unfortunately there is not much we can do in this case. This error happens from a pass in the compiler that is very far removed from the original code, so any extra information is lost. The location: :keep affects the runtime behaviour but the definition code uses the caller information, otherwise we would actually report:
warning: this clause cannot match because a previous clause at line 4 always matches
lib/bug_test.ex:4
Environment
Current behavior
When using
location: :keep
, "cannot match" warnings are generated with the file name where the macro is defined but line number where the macro is called.Generates the warning
If the macro is defined without
location: :keep
, the warning isExpected behavior
I'm not sure if this is a bug or my misunderstanding, but the first warning looks weird, since the lines 113 and 114 don't even exist in
bug_test.ex
.I understand that it's tricky to show a proper warning message here because the issue comes from calling the macro twice, so we need to reference this. However, I think a clearer warning message would be something like:
or simply
That way, if we had multiple functions being generated by the
generate_function
macro we could see which function cannot be matched.The text was updated successfully, but these errors were encountered: