File tree Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Expand file tree Collapse file tree 2 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -148,10 +148,13 @@ impl TranslateModule for FunctionInvocation {
148148 arg. get_var_translated_name ( ) . unwrap ( )
149149 } else {
150150 let translation = arg. translate_eval ( meta, false ) ;
151+
151152 // If the argument is an array, we have to get just the "name[@]" part
152- ( translation. starts_with ( "\" ${" ) && translation. ends_with ( "[@]}\" " ) )
153- . then ( || translation. get ( 3 ..translation. len ( ) - 2 ) . unwrap ( ) . to_string ( ) )
154- . unwrap_or ( translation)
153+ if translation. starts_with ( "\" ${" ) && translation. ends_with ( "[@]}\" " ) {
154+ translation. get ( 3 ..translation. len ( ) - 2 ) . unwrap ( ) . to_string ( )
155+ } else {
156+ translation
157+ }
155158 }
156159 } ) . collect :: < Vec < String > > ( ) . join ( " " ) ;
157160
Original file line number Diff line number Diff line change @@ -96,8 +96,8 @@ impl SyntaxModule<ParserMetadata> for VariableInit {
9696 panic!( "Expected array type for destructured variable" ) ;
9797 }
9898
99- for mut def in & mut definitions {
100- self . handle_add_variable( meta, & mut def) ?;
99+ for def in & mut definitions {
100+ self . handle_add_variable( meta, def) ?;
101101 }
102102
103103 self . is_global_ctx = definitions. iter( ) . any( |x| x. global_id. is_some( ) ) ;
@@ -124,7 +124,6 @@ impl TranslateModule for VariableInit {
124124 expr = format ! ( "({expr})" ) ;
125125 }
126126
127- let mut idx = 0 ;
128127 let is_destructured = self . definitions . len ( ) > 1 ;
129128 let mut out = String :: new ( ) ;
130129
@@ -160,11 +159,11 @@ impl TranslateModule for VariableInit {
160159 ) ;
161160 }
162161
163- for def in & self . definitions {
162+ for ( idx , def) in self . definitions . iter ( ) . enumerate ( ) {
164163 let expr = if is_destructured {
165164 format ! ( "${{{}[{}]}};\n " , reference. clone( ) . unwrap( ) , idx)
166165 } else {
167- format ! ( "{}" , expr)
166+ expr. clone ( )
168167 } ;
169168
170169 if let Some ( id) = def. global_id {
@@ -174,8 +173,6 @@ impl TranslateModule for VariableInit {
174173 } else {
175174 out. push_str ( format ! ( "{name}={expr}" , name = def. name) . as_str ( ) )
176175 }
177-
178- idx += 1 ;
179176 }
180177
181178 out
You can’t perform that action at this time.
0 commit comments