Unclear exception raised without reference to program text when `raise :symbol` appears in source
Closed this issue · 3 comments
Elixir and Erlang/OTP versions
Erlang/OTP 27 [erts-15.1.3] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit:ns]
Elixir 1.17.3 (compiled with Erlang/OTP 27)
Operating system
Arch Linux
Current behavior
When compiling the following file with elixirc a.ex
:
defmodule A do
def foo do
raise :todo
end
end
A rather unhelpful error message appears indicating a problem in elixir's Module.ParallelChecker, which doesn't indicate what if anything in the program text is wrong:
** (EXIT from #PID<0.95.0>) an exception was raised:
** (FunctionClauseError) no function clause matching in :lists.duplicate/2
(stdlib 6.1.2) lists.erl:510: :lists.duplicate(-3, 126)
(elixir 1.17.3) src/elixir_errors.erl:223: :elixir_errors.highlight_below_line/2
(elixir 1.17.3) src/elixir_errors.erl:156: :elixir_errors.format_snippet/6
(elixir 1.17.3) src/elixir_errors.erl:74: :elixir_errors.print_diagnostic/2
(elixir 1.17.3) lib/module/parallel_checker.ex:323: anonymous fn/2 in Module.ParallelChecker.emit_warnings/2
(elixir 1.17.3) lib/enum.ex:4353: Enum.flat_map_list/2
(elixir 1.17.3) lib/module/parallel_checker.ex:267: Module.ParallelChecker.check_module/3
(elixir 1.17.3) lib/module/parallel_checker.ex:82: anonymous fn/6 in Module.ParallelChecker.spawn/4
Expected behavior
elixirc tells me about the problem with my source code.
At the suggestion of some kind folks in the elixir irc chat, I used break!
to hop into parallel_checker.ex:323, which did seem to have error information about the unacceptable argument to raise
at the time of the error.
Unfortunately I cannot reproduce this:
~/OSS/phoenix[main %]$ elixirc a.ex
warning: redefining module A (current version loaded from Elixir.A.beam)
│
1 │ defmodule A do
│ ~~~~~~~~~~~~~~
│
└─ a.ex:1: A (module)
warning: :todo.exception/1 is undefined (module :todo is not available or is yet to be defined)
│
3 │ raise :todo
│ ~~~~~~~~~~~
│
└─ a.ex:3: A.foo/0
I will try to look at the stacktrace though and understand what is going wrong.
I got this! The error only happens if you use tabs for indentation.
That'll do it :D