@@ -54,7 +54,7 @@ defmodule Kernel.RecordRewriter do
5454
5555 defp record_field_info ( function ) do
5656 case atom_to_list ( function ) do
57- 'update_' ++ field -> { :update , list_to_atom ( function ) }
57+ 'update_' ++ field -> { :update , list_to_atom ( field ) }
5858 _ -> { :accessor , function }
5959 end
6060 end
@@ -65,7 +65,7 @@ defmodule Kernel.RecordRewriter do
6565 if List . member? ( optimizable , { function , length ( args ) + 1 } ) do
6666 { kind , field } = record_field_info ( function )
6767 if index = Enum . find_index ( fields , field == & 1 ) do
68- optimize_call ( line , res , kind , index , left , args )
68+ optimize_call ( line , res , kind , field , index , left , args )
6969 end
7070 end
7171 nil -> nil
@@ -76,24 +76,28 @@ defmodule Kernel.RecordRewriter do
7676 nil
7777 end
7878
79- defp optimize_call ( line , _res , :accessor , index , left , [ ] ) do
79+ defp optimize_call ( line , _res , :accessor , _field , index , left , [ ] ) do
8080 call = { :call , line ,
8181 { :remote , line , { :atom , 0 , :erlang } , { :atom , 0 , :element } } ,
8282 [ { :integer , 0 , index + 2 } , left ]
8383 }
8484 { call , nil }
8585 end
8686
87- defp optimize_call ( line , res , :accessor , index , left , [ arg ] ) do
87+ defp optimize_call ( line , res , :accessor , _field , index , left , [ arg ] ) do
8888 call = { :call , line ,
8989 { :remote , line , { :atom , 0 , :erlang } , { :atom , 0 , :setelement } } ,
9090 [ { :integer , 0 , index + 2 } , left , arg ]
9191 }
9292 { call , res }
9393 end
9494
95- defp optimize_call ( _line , _res , :update , _index , _left , [ _arg ] ) do
96- nil
95+ defp optimize_call ( line , res , :update , field , _index , left , args ) do
96+ call = { :call , line ,
97+ { :remote , line , left , { :atom , 0 , :"update_#{ field } " } } ,
98+ args
99+ }
100+ { call , res }
97101 end
98102
99103 ## Expr
0 commit comments