Skip to content

Commit 2096f41

Browse files
committed
Convert only the pattern matching suggestion into a hint
1 parent 9d845cf commit 2096f41

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lib/elixir/lib/module/types/expr.ex

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ defmodule Module.Types.Expr do
810810
{:%, _, [module, {:%{}, _, [{:|, _, [map, _]}]}]} = expr
811811
traces = collect_traces(map, context)
812812

813-
suggestion =
813+
fix =
814814
case map do
815815
{var, meta, context} when is_atom(var) and is_atom(context) ->
816816
if capture = meta[:capture] do
@@ -839,9 +839,11 @@ defmodule Module.Types.Expr do
839839
format_traces(traces),
840840
"""
841841
842-
#{hint()} #{suggestion}. Given pattern matching is enough to catch typing errors, \
843-
you may optionally convert the struct update into a map update. For example, \
844-
instead of:
842+
#{fix}.
843+
844+
#{hint()} given pattern matching is enough to catch typing errors, \
845+
you may optionally convert the struct update into a map update. For \
846+
example, instead of:
845847
846848
user = some_fun()
847849
%User{user | name: "John Doe"}

lib/elixir/test/elixir/module/types/expr_test.exs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,9 @@ defmodule Module.Types.ExprTest do
900900
# from: types_test.ex:LINE
901901
x
902902
903-
hint: when defining the variable "x", you must also pattern match on "%Date{}". Given pattern matching is enough to catch typing errors, you may optionally convert the struct update into a map update. For example, instead of:
903+
when defining the variable "x", you must also pattern match on "%Date{}".
904+
905+
hint: given pattern matching is enough to catch typing errors, you may optionally convert the struct update into a map update. For example, instead of:
904906
905907
user = some_fun()
906908
%User{user | name: "John Doe"}
@@ -927,7 +929,7 @@ defmodule Module.Types.ExprTest do
927929
# from: types_test.ex:LINE
928930
&1
929931
930-
hint: instead of using &1, you must define an anonymous function, define a variable and pattern match on "%Date{}"\
932+
instead of using &1, you must define an anonymous function, define a variable and pattern match on "%Date{}".
931933
"""
932934

933935
# When we don't know the type of expression
@@ -940,7 +942,7 @@ defmodule Module.Types.ExprTest do
940942
941943
dynamic()
942944
943-
hint: you must assign "SomeMod.fun()" to variable and pattern match on "%Date{}".\
945+
you must assign "SomeMod.fun()" to variable and pattern match on "%Date{}".
944946
"""
945947
end
946948

0 commit comments

Comments
 (0)