Skip to content

Commit b93aae9

Browse files
author
José Valim
committed
Ensure we quote proper file on exceptions
Signed-off-by: José Valim <[email protected]> Conflicts: lib/elixir/test/elixir/exception_test.exs
1 parent a503069 commit b93aae9

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/elixir/src/elixir_dispatch.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ expand_quoted(Meta, Receiver, Name, Arity, Quoted, E) ->
215215
end.
216216

217217
caller(Line, #{module := nil} = E) ->
218-
{elixir_compiler, '__FILE__', 2, location(Line, E)};
218+
{elixir_compiler_0, '__FILE__', 1, location(Line, E)};
219219
caller(Line, #{module := Module, function := nil} = E) ->
220220
{Module, '__MODULE__', 0, location(Line, E)};
221221
caller(Line, #{module := Module, function := {Name, Arity}} = E) ->

lib/elixir/test/elixir/exception_test.exs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,4 +327,20 @@ defmodule Kernel.ExceptionTest do
327327
assert %ErlangError{original: :sample} |> message ==
328328
"erlang error: :sample"
329329
end
330+
331+
test "format_stacktrace from file" do
332+
assert_raise ArgumentError, fn ->
333+
Code.eval_string("def foo do end", [], file: "myfile")
334+
end
335+
336+
assert Exception.format_stacktrace(System.stacktrace) =~ "myfile:1: (file)"
337+
end
338+
339+
test "format_stacktrace from module" do
340+
assert_raise ArgumentError, fn ->
341+
Code.eval_string("defmodule Foo do raise ArgumentError, ~s(oops) end", [], file: "myfile")
342+
end
343+
344+
assert Exception.format_stacktrace(System.stacktrace) =~ "myfile:1: (module)"
345+
end
330346
end

0 commit comments

Comments
 (0)