@@ -3409,7 +3409,7 @@ defmodule Kernel do
34093409
34103410 """
34113411 defmacro to_charlist ( term ) do
3412- quote ( do: List.Chars . to_charlist ( unquote ( term ) ) )
3412+ quote ( do: :"Elixir. List.Chars" . to_charlist ( unquote ( term ) ) )
34133413 end
34143414
34153415 @ doc """
@@ -4064,7 +4064,7 @@ defmodule Kernel do
40644064 - 1
40654065 end
40664066
4067- { :%{} , [ ] , [ __struct__: Elixir.Range , first: first , last: last , step: step ] }
4067+ { :% , [ ] , [ Elixir.Range , { :%{} , [ ] , [ first: first , last: last , step: step ] } ] }
40684068 end
40694069
40704070 defp stepless_range ( nil , first , last , _caller ) do
@@ -4090,7 +4090,7 @@ defmodule Kernel do
40904090 Macro.Env . stacktrace ( caller )
40914091 )
40924092
4093- { :%{} , [ ] , [ __struct__: Elixir.Range , first: first , last: last , step: step ] }
4093+ { :% , [ ] , [ Elixir.Range , { :%{} , [ ] , [ first: first , last: last , step: step ] } ] }
40944094 end
40954095
40964096 defp stepless_range ( :match , first , last , caller ) do
@@ -4103,7 +4103,7 @@ defmodule Kernel do
41034103 Macro.Env . stacktrace ( caller )
41044104 )
41054105
4106- { :%{} , [ ] , [ __struct__: Elixir.Range , first: first , last: last ] }
4106+ { :% , [ ] , [ Elixir.Range , { :%{} , [ ] , [ first: first , last: last ] } ] }
41074107 end
41084108
41094109 @ doc """
@@ -4142,14 +4142,14 @@ defmodule Kernel do
41424142 range ( __CALLER__ . context , first , last , step )
41434143
41444144 false ->
4145- range ( __CALLER__ . context , first , last , step )
4145+ { :%{} , [ ] , [ __struct__: Elixir.Range , first: first , last: last , step: step ] }
41464146 end
41474147 end
41484148
41494149 defp range ( context , first , last , step )
41504150 when is_integer ( first ) and is_integer ( last ) and is_integer ( step )
41514151 when context != nil do
4152- { :%{} , [ ] , [ __struct__: Elixir.Range , first: first , last: last , step: step ] }
4152+ { :% , [ ] , [ Elixir.Range , { :%{} , [ ] , [ first: first , last: last , step: step ] } ] }
41534153 end
41544154
41554155 defp range ( nil , first , last , step ) do
@@ -4559,11 +4559,10 @@ defmodule Kernel do
45594559 raise ArgumentError , "found unescaped value on the right side of in/2: #{ inspect ( right ) } "
45604560
45614561 right ->
4562- with { :%{} , _meta , fields } <- right ,
4563- [ __struct__: Elixir.Range , first: first , last: last , step: step ] <-
4564- :lists . usort ( fields ) do
4565- in_var ( in_body? , left , & in_range ( & 1 , expand . ( first ) , expand . ( last ) , expand . ( step ) ) )
4566- else
4562+ case range_fields ( right ) do
4563+ [ first: first , last: last , step: step ] ->
4564+ in_var ( in_body? , left , & in_range ( & 1 , expand . ( first ) , expand . ( last ) , expand . ( step ) ) )
4565+
45674566 _ when in_body? ->
45684567 quote ( do: Elixir.Enum . member? ( unquote ( right ) , unquote ( left ) ) )
45694568
@@ -4573,6 +4572,10 @@ defmodule Kernel do
45734572 end
45744573 end
45754574
4575+ defp range_fields ( { :% , _ , [ Elixir.Range , { :%{} , _ , fields } ] } ) , do: :lists . usort ( fields )
4576+ defp range_fields ( { :%{} , _ , [ __struct__: Elixir.Range ] ++ fields } ) , do: :lists . usort ( fields )
4577+ defp range_fields ( _ ) , do: [ ]
4578+
45764579 defp raise_on_invalid_args_in_2 ( right ) do
45774580 raise ArgumentError , <<
45784581 "invalid right argument for operator \" in\" , it expects a compile-time proper list " ,
@@ -5385,7 +5388,7 @@ defmodule Kernel do
53855388
53865389 john = %User{name: "John"}
53875390 MyProtocol.call(john)
5388- ** (Protocol.UndefinedError) protocol MyProtocol not implemented for % User{...}
5391+ ** (Protocol.UndefinedError) protocol MyProtocol not implemented for User (a struct)
53895392
53905393 `defstruct/1`, however, allows protocol implementations to be
53915394 *derived*. This can be done by defining a `@derive` attribute as a
0 commit comments