@@ -191,12 +191,11 @@ def _HasManyStatuses(node):
191
191
192
192
193
193
def ListInitializeTarget (old_val ,
194
- initializer ,
195
194
has_plus ,
196
195
exec_opts ,
197
196
blame_loc ,
198
197
destructive = True ):
199
- # type: (value_t, value.InitializerList, bool, optview.Exec, loc_t, bool) -> value_t
198
+ # type: (value_t, bool, optview.Exec, loc_t, bool) -> value_t
200
199
UP_old_val = old_val
201
200
with tagswitch (old_val ) as case :
202
201
if case (value_e .Undef ):
@@ -219,13 +218,6 @@ def ListInitializeTarget(old_val,
219
218
old_val = bash_impl .BashArray_New ()
220
219
return old_val
221
220
elif case (value_e .BashAssoc ):
222
- # OSH compatibility: assoc=(1 2) will create a new array. This
223
- # code will soon be removed when the initialization of the form
224
- # "assoc=(key value)" is supported.
225
- if (not has_plus and len (initializer .assigns ) > 0 and
226
- initializer .assigns [0 ].key is None ):
227
- return bash_impl .BashArray_New ()
228
-
229
221
old_val = cast (value .BashAssoc , UP_old_val )
230
222
if not destructive :
231
223
if has_plus :
@@ -239,8 +231,8 @@ def ListInitializeTarget(old_val,
239
231
ui .ValType (old_val ), blame_loc )
240
232
241
233
242
- def ListInitialize (val , initializer , has_plus , blame_loc , arith_ev ):
243
- # type: (value_t, value.InitializerList, bool, loc_t, sh_expr_eval.ArithEvaluator) -> None
234
+ def ListInitialize (val , initializer , has_plus , exec_opts , blame_loc , arith_ev ):
235
+ # type: (value_t, value.InitializerList, bool, optview.Exec, loc_t, sh_expr_eval.ArithEvaluator) -> None
244
236
UP_val = val
245
237
with tagswitch (val ) as case :
246
238
if case (value_e .BashArray ):
@@ -250,7 +242,7 @@ def ListInitialize(val, initializer, has_plus, blame_loc, arith_ev):
250
242
elif case (value_e .BashAssoc ):
251
243
val = cast (value .BashAssoc , UP_val )
252
244
bash_impl .BashAssoc_ListInitialize (val , initializer , has_plus ,
253
- blame_loc )
245
+ exec_opts , blame_loc )
254
246
else :
255
247
raise AssertionError (val .tag ())
256
248
@@ -627,7 +619,6 @@ def _EvalTempEnv(self, more_env, flags):
627
619
None , # No nounset
628
620
e_pair .left )
629
621
val = ListInitializeTarget (old_val ,
630
- initializer ,
631
622
has_plus ,
632
623
self .exec_opts ,
633
624
e_pair .left ,
@@ -641,8 +632,8 @@ def _EvalTempEnv(self, more_env, flags):
641
632
flags = flags )
642
633
643
634
if initializer is not None :
644
- ListInitialize (val , initializer , has_plus , e_pair . left ,
645
- self .arith_ev )
635
+ ListInitialize (val , initializer , has_plus , self . exec_opts ,
636
+ e_pair . left , self .arith_ev )
646
637
647
638
def _StrictErrExit (self , node ):
648
639
# type: (command_t) -> None
@@ -1045,8 +1036,8 @@ def _DoShAssignment(self, node, cmd_st):
1045
1036
old_val = sh_expr_eval .OldValue (lval , self .mem , None ,
1046
1037
node .left )
1047
1038
1048
- val = ListInitializeTarget (old_val , initializer , has_plus ,
1049
- self . exec_opts , pair .left )
1039
+ val = ListInitializeTarget (old_val , has_plus , self . exec_opts ,
1040
+ pair .left )
1050
1041
1051
1042
elif has_plus :
1052
1043
# do not respect set -u
@@ -1065,8 +1056,8 @@ def _DoShAssignment(self, node, cmd_st):
1065
1056
flags = 0 # for tracing
1066
1057
self .mem .SetValue (lval , val , which_scopes , flags = flags )
1067
1058
if initializer is not None :
1068
- ListInitialize (val , initializer , has_plus , pair . left ,
1069
- self .arith_ev )
1059
+ ListInitialize (val , initializer , has_plus , self . exec_opts ,
1060
+ pair . left , self .arith_ev )
1070
1061
1071
1062
self .tracer .OnShAssignment (lval , pair .op , rhs , flags , which_scopes )
1072
1063
0 commit comments