Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:20
elixir
0001-Fixes-for-Erlang-OTP-23.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Fixes-for-Erlang-OTP-23.patch of Package elixir
From 351cff9d950f228f0b01ac54410c2f961ca03d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= <jose.valim@dashbit.co> Date: Wed, 26 Feb 2020 12:05:45 +0100 Subject: [PATCH] Fixes for Erlang/OTP 23 --- lib/elixir/lib/map.ex | 2 -- lib/elixir/src/elixir_erl.erl | 9 ++----- lib/elixir/src/elixir_erl_compiler.erl | 8 ++++++ lib/elixir/src/elixir_utils.erl | 10 +++++--- .../test/elixir/kernel/parallel_compiler_test.exs | 8 ++---- lib/elixir/test/elixir/kernel/warning_test.exs | 30 ++++++---------------- 6 files changed, 27 insertions(+), 40 deletions(-) diff --git a/lib/elixir/lib/map.ex b/lib/elixir/lib/map.ex index 066bcb3bd..c8058341d 100644 --- a/lib/elixir/lib/map.ex +++ b/lib/elixir/lib/map.ex @@ -265,8 +265,6 @@ defmodule Map do iex> Map.fetch!(%{a: 1}, :a) 1 - iex> Map.fetch!(%{a: 1}, :b) - ** (KeyError) key :b not found in: %{a: 1} """ @spec fetch!(map, key) :: value diff --git a/lib/elixir/src/elixir_erl.erl b/lib/elixir/src/elixir_erl.erl index d124c1119..ebeb6a104 100644 --- a/lib/elixir/src/elixir_erl.erl +++ b/lib/elixir/src/elixir_erl.erl @@ -54,13 +54,8 @@ definition_to_anonymous(Module, Kind, Meta, Clauses) -> {value, Result, _Binding} = erl_eval:expr(Fun, [], {value, LocalHandler}), Result. -invoke_local(Module, RawName, Args) -> - %% If we have a macro, its arity in the table is - %% actually one less than in the function call - {Name, Arity} = case atom_to_list(RawName) of - "MACRO-" ++ Rest -> {list_to_atom(Rest), length(Args) - 1}; - _ -> {RawName, length(Args)} - end, +invoke_local(Module, ErlName, Args) -> + {Name, Arity} = elixir_utils:erl_fa_to_elixir_fa(ErlName, length(Args)), case elixir_def:local_for(Module, Name, Arity, all) of false -> diff --git a/lib/elixir/src/elixir_erl_compiler.erl b/lib/elixir/src/elixir_erl_compiler.erl index 20a60b2f8..bcc94c31c 100644 --- a/lib/elixir/src/elixir_erl_compiler.erl +++ b/lib/elixir/src/elixir_erl_compiler.erl @@ -134,6 +134,14 @@ custom_format(sys_core_fold, {eval_failure, Error}) -> #{'__struct__' := Struct} = 'Elixir.Exception':normalize(error, Error), ["this expression will fail with ", elixir_aliases:inspect(Struct)]; +custom_format(sys_core_fold, {nomatch_shadow,Line,{ErlName,ErlArity}}) -> + {Name, Arity} = elixir_utils:erl_fa_to_elixir_fa(ErlName, ErlArity), + + io_lib:format( + "this clause for ~ts/~B cannot match because a previous clause at line ~B always matches", + [Name, Arity, Line] + ); + custom_format([], Desc) -> io_lib:format("~p", [Desc]); diff --git a/lib/elixir/src/elixir_utils.erl b/lib/elixir/src/elixir_utils.erl index 41551156e..7a1e12737 100644 --- a/lib/elixir/src/elixir_utils.erl +++ b/lib/elixir/src/elixir_utils.erl @@ -7,15 +7,19 @@ read_file_type/1, read_file_type/2, read_link_type/1, read_posix_mtime_and_size/1, change_posix_time/2, change_universal_time/2, guard_op/2, extract_splat_guards/1, extract_guards/1, - erlang_comparison_op_to_elixir/1]). + erlang_comparison_op_to_elixir/1, erl_fa_to_elixir_fa/2]). -include("elixir.hrl"). -include_lib("kernel/include/file.hrl"). -% Builds the macro name - macro_name(Macro) -> list_to_atom("MACRO-" ++ atom_to_list(Macro)). +erl_fa_to_elixir_fa(Name, Arity) -> + case atom_to_list(Name) of + "MACRO-" ++ Rest -> {list_to_atom(Rest), Arity - 1}; + _ -> {Name, Arity} + end. + guard_op('andalso', 2) -> true; guard_op('orelse', 2) -> diff --git a/lib/elixir/test/elixir/kernel/parallel_compiler_test.exs b/lib/elixir/test/elixir/kernel/parallel_compiler_test.exs index 663e0a186..6bfab24b2 100644 --- a/lib/elixir/test/elixir/kernel/parallel_compiler_test.exs +++ b/lib/elixir/test/elixir/kernel/parallel_compiler_test.exs @@ -233,8 +233,7 @@ defmodule Kernel.ParallelCompilerTest do msg = capture_io(:stderr, fn -> assert {:error, [error], []} = Kernel.ParallelCompiler.compile([fixture]) - msg = "this clause cannot match because a previous clause at line 2 always matches" - assert error == {fixture, 3, msg} + assert {^fixture, 3, "this clause " <> _} = error end) assert msg =~ @@ -377,10 +376,7 @@ defmodule Kernel.ParallelCompilerTest do capture_io(:stderr, fn -> assert {:error, [error], []} = Kernel.ParallelCompiler.require([fixture]) - message = - "this clause cannot match because a previous clause at line 2 always matches" - - assert error == {fixture, 3, message} + assert {^fixture, 3, "this clause " <> _} = error end) assert msg =~ diff --git a/lib/elixir/test/elixir/kernel/warning_test.exs b/lib/elixir/test/elixir/kernel/warning_test.exs index 972036c14..969e9c4f8 100644 --- a/lib/elixir/test/elixir/kernel/warning_test.exs +++ b/lib/elixir/test/elixir/kernel/warning_test.exs @@ -661,24 +661,6 @@ defmodule Kernel.WarningTest do purge(Sample) end - test "previous clause always matches" do - assert capture_err(fn -> - Code.eval_string(""" - defmodule Sample do - def binary_cond do - v = "bc" - cond do - is_binary(v) -> :bin - true -> :ok - end - end - end - """) - end) =~ "this clause cannot match because a previous clause at line 5 always matches" - after - purge(Sample) - end - test "empty clause" do assert capture_err(fn -> Code.eval_string(""" @@ -740,7 +722,8 @@ defmodule Kernel.WarningTest do def hello, do: nil end """) - end) =~ "this clause cannot match because a previous clause at line 2 always matches" + end) =~ + ~r"this clause( for hello/0)? cannot match because a previous clause at line 2 always matches" after purge(Sample) end @@ -760,7 +743,8 @@ defmodule Kernel.WarningTest do use Sample end """) - end) =~ "this clause cannot match because a previous clause at line 10 always matches" + end) =~ + ~r"this clause( for hello/0)? cannot match because a previous clause at line 10 always matches" after purge(Sample) purge(UseSample) @@ -1613,7 +1597,8 @@ defmodule Kernel.WarningTest do defguard foo(baz) when baz == :baz end """) - end) =~ "this clause cannot match because a previous clause at line 2 always matches" + end) =~ + ~r"this clause( for foo/1)? cannot match because a previous clause at line 2 always matches" after purge(Sample) end @@ -1626,7 +1611,8 @@ defmodule Kernel.WarningTest do defmacro foo(bar), do: bar == :bar end """) - end) =~ "this clause cannot match because a previous clause at line 2 always matches" + end) =~ + ~r"this clause( for foo/1)? cannot match because a previous clause at line 2 always matches" after purge(Sample) end -- 2.16.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor