Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear exception raised without reference to program text when raise :symbol appears in source #14073

Closed
slondr opened this issue Dec 16, 2024 · 3 comments

Comments

@slondr
Copy link

slondr commented Dec 16, 2024

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.

@josevalim
Copy link
Member

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.

@josevalim
Copy link
Member

I got this! The error only happens if you use tabs for indentation.

@slondr
Copy link
Author

slondr commented Dec 18, 2024

That'll do it :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants