Skip to content

Commit 3e54b95

Browse files
author
José Valim
committed
Fix the build
1 parent 313d26c commit 3e54b95

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

lib/elixir/lib/exception.ex

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -613,12 +613,12 @@ defmodule BadArityError do
613613
end
614614

615615
defmodule UndefinedFunctionError do
616-
defexception [module: nil, function: nil, arity: nil]
616+
defexception [module: nil, function: nil, arity: nil, self: false]
617617

618-
def message(%{function: function, module: module, arity: arity}) do
618+
def message(%{function: function, module: module, arity: arity, self: self}) do
619619
if function do
620620
formatted = Exception.format_mfa module, function, arity
621-
suffix = if nil?(module) || :code.is_loaded(module) do
621+
suffix = if self or nil?(module) or :code.is_loaded(module) do
622622
""
623623
else
624624
" (module #{inspect module} is not available)"
@@ -777,8 +777,9 @@ defmodule ErlangError do
777777
end
778778

779779
def normalize(:undef, stacktrace) do
780-
{mod, fun, arity} = from_stacktrace(stacktrace || :erlang.get_stacktrace)
781-
%UndefinedFunctionError{module: mod, function: fun, arity: arity}
780+
stacktrace = stacktrace || :erlang.get_stacktrace
781+
{mod, fun, arity} = from_stacktrace(stacktrace)
782+
%UndefinedFunctionError{module: mod, function: fun, arity: arity, self: from_self(stacktrace)}
782783
end
783784

784785
def normalize(:function_clause, stacktrace) do
@@ -805,4 +806,7 @@ defmodule ErlangError do
805806
defp from_stacktrace(_) do
806807
{nil, nil, nil}
807808
end
809+
810+
defp from_self([{module, _, _, _}, {module, _, _, _}|_]), do: true
811+
defp from_self(_), do: false
808812
end

lib/elixir/test/elixir/kernel/raise_test.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ defmodule Kernel.RaiseTest do
226226
x in [UndefinedFunctionError] -> Exception.message(x)
227227
end
228228

229-
assert result == "undefined function: DoNotExist.for_sure/0"
229+
assert result == "undefined function: DoNotExist.for_sure/0 (module DoNotExist is not available)"
230230
end
231231

232232
test :function_clause_error do
@@ -352,7 +352,7 @@ defmodule Kernel.RaiseTest do
352352
x in [ErlangError] -> Exception.message(x)
353353
end
354354

355-
assert result == "undefined function: DoNotExist.for_sure/0"
355+
assert result == "undefined function: DoNotExist.for_sure/0 (module DoNotExist is not available)"
356356
end
357357

358358
defmacrop exceptions do
@@ -366,7 +366,7 @@ defmodule Kernel.RaiseTest do
366366
x in exceptions -> Exception.message(x)
367367
end
368368

369-
assert result == "undefined function: DoNotExist.for_sure/0"
369+
assert result == "undefined function: DoNotExist.for_sure/0 (module DoNotExist is not available)"
370370
end
371371

372372
defp zero(0), do: 0

lib/ex_unit/test/ex_unit/assertions_test.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ defmodule ExUnit.AssertionsTest do
226226
end
227227
rescue
228228
error in [ExUnit.AssertionError] ->
229-
"Expected exception ArgumentError but got UndefinedFunctionError (undefined function: Not.Defined.function/3)" = error.message
229+
"Expected exception ArgumentError but got UndefinedFunctionError " <>
230+
"(undefined function: Not.Defined.function/3 (module Not.Defined is not available))" = error.message
230231
end
231232

232233
test "assert raise with erlang error" do

lib/ex_unit/test/ex_unit/doc_test_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ defmodule ExUnit.DocTestTest do
239239
assert output =~ """
240240
4) test moduledoc at ExUnit.DocTestTest.Invalid (4) (ExUnit.DocTestTest.ActuallyCompiled)
241241
test/ex_unit/doc_test_test.exs:204
242-
Doctest failed: got UndefinedFunctionError with message undefined function: Hello.world/0
242+
Doctest failed: got UndefinedFunctionError with message undefined function: Hello.world/0 (module Hello is not available)
243243
code: Hello.world
244244
stacktrace:
245245
test/ex_unit/doc_test_test.exs:112: ExUnit.DocTestTest.Invalid (module)

lib/iex/test/iex/helpers_test.exs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ defmodule IEx.HelpersTest do
168168
end
169169

170170
test "c helper" do
171-
assert_raise UndefinedFunctionError, "undefined function: Sample.run/0", fn ->
171+
assert_raise UndefinedFunctionError, ~r"undefined function: Sample\.run/0", fn ->
172172
Sample.run
173173
end
174174

@@ -192,7 +192,7 @@ defmodule IEx.HelpersTest do
192192
end
193193

194194
test "c helper multiple modules" do
195-
assert_raise UndefinedFunctionError, "undefined function: Sample.run/0", fn ->
195+
assert_raise UndefinedFunctionError, ~r"undefined function: Sample.run/0", fn ->
196196
Sample.run
197197
end
198198

@@ -207,7 +207,7 @@ defmodule IEx.HelpersTest do
207207
end
208208

209209
test "c helper list" do
210-
assert_raise UndefinedFunctionError, "undefined function: Sample.run/0", fn ->
210+
assert_raise UndefinedFunctionError, ~r"undefined function: Sample.run/0", fn ->
211211
Sample.run
212212
end
213213

@@ -222,7 +222,7 @@ defmodule IEx.HelpersTest do
222222
end
223223

224224
test "c helper erlang" do
225-
assert_raise UndefinedFunctionError, "undefined function: :sample.hello/0", fn ->
225+
assert_raise UndefinedFunctionError, ~r"undefined function: :sample.hello/0", fn ->
226226
:sample.hello
227227
end
228228

@@ -237,7 +237,7 @@ defmodule IEx.HelpersTest do
237237

238238

239239
test "c helper skips unknown files" do
240-
assert_raise UndefinedFunctionError, "undefined function: :sample.hello/0", fn ->
240+
assert_raise UndefinedFunctionError, ~r"undefined function: :sample.hello/0", fn ->
241241
:sample.hello
242242
end
243243

@@ -253,7 +253,7 @@ defmodule IEx.HelpersTest do
253253

254254

255255
test "l helper" do
256-
assert_raise UndefinedFunctionError, "undefined function: Sample.run/0", fn ->
256+
assert_raise UndefinedFunctionError, ~r"undefined function: Sample.run/0", fn ->
257257
Sample.run
258258
end
259259

@@ -284,7 +284,7 @@ defmodule IEx.HelpersTest do
284284
end
285285

286286
test "r helper elixir" do
287-
assert_raise UndefinedFunctionError, "undefined function: Sample.run/0", fn ->
287+
assert_raise UndefinedFunctionError, ~r"undefined function: Sample.run/0", fn ->
288288
Sample.run
289289
end
290290

@@ -307,7 +307,7 @@ defmodule IEx.HelpersTest do
307307
end
308308

309309
test "r helper erlang" do
310-
assert_raise UndefinedFunctionError, "undefined function: :sample.hello/0", fn ->
310+
assert_raise UndefinedFunctionError, ~r"undefined function: :sample.hello/0", fn ->
311311
:sample.hello
312312
end
313313

0 commit comments

Comments
 (0)