@@ -55,37 +55,40 @@ let substitue_variables (map : Ident.t Map_ident.t) =
55
55
since we have to guarantee that the one use
56
56
case is substituted
57
57
we already have this? in [defined_idents]
58
+
59
+ At this time, when tailcall happened, the parameter can be assigned
60
+ for example {[
61
+ function (_x,y){
62
+ _x = u
63
+ }
64
+ ]}
65
+ if it is substitued, the assignment will align the value which is incorrect
58
66
*)
59
67
60
68
let inline_call
61
- no_tailcall
62
- params (args : J.expression list ) processed_blocks =
63
- if no_tailcall then
64
- let map, block =
69
+ ( immutable_list : bool list )
70
+ params (args : J.expression list ) processed_blocks =
71
+ let map, block =
72
+ if immutable_list = [] then
65
73
Ext_list. fold_right2
66
74
params args (Map_ident. empty, processed_blocks)
67
75
(fun param arg (map ,acc ) ->
68
76
match arg.expression_desc with
69
77
| Var (Id id ) ->
70
78
Map_ident. add map param id, acc
71
79
| _ ->
72
- map, S. define_variable ~kind: Variable param arg :: acc) in
73
- if Map_ident. is_empty map then block
74
- else (substitue_variables map) # block block
75
- else
76
- (*
77
- At this time, when tailcall happened, the parameter can be assigned
78
- for example {[
79
- function (_x,y){
80
- _x = u
81
- }
82
- ]}
83
- if it is substitued, the assignment will align the value which is incorrect
84
- *)
85
- Ext_list. fold_right2
86
- params args processed_blocks
87
- (fun param arg acc ->
88
- S. define_variable ~kind: Variable param arg :: acc)
80
+ map, S. define_variable ~kind: Variable param arg :: acc)
81
+ else
82
+ Ext_list. fold_right3
83
+ params args immutable_list (Map_ident. empty, processed_blocks)
84
+ (fun param arg mask (map ,acc ) ->
85
+ match mask, arg.expression_desc with
86
+ | true , Var (Id id ) ->
87
+ Map_ident. add map param id, acc
88
+ | _ ->
89
+ map, S. define_variable ~kind: Variable param arg :: acc) in
90
+ if Map_ident. is_empty map then block
91
+ else (substitue_variables map) # block block
89
92
90
93
(* * There is a side effect when traversing dead code, since
91
94
we assume that substitue a node would mark a node as dead node,
0 commit comments