@@ -164,43 +164,56 @@ fn (mut app App) decl_stmt(d DeclStmt) {
164
164
for spec in d.decl.specs {
165
165
match spec {
166
166
ValueSpec {
167
- n := spec.names[0 ].name
168
- if app.cur_fn_names[n] {
169
- println ('${n} already declared in cur fn. skipping. (why does this happen?)' )
170
- return
171
- }
172
- // app.genln('// value spec')
173
167
app.gen ('mut ' )
174
- if n == 'layerDuplicates2' {
175
- // app.genln('${d}')
176
- println ('=================' )
177
- print_backtrace ()
178
- println ('1111111111111111111111' )
168
+ for idx in 0 .. spec.names.len {
169
+ if idx > 0 {
170
+ app.gen (',' )
171
+ }
172
+ n := spec.names[idx].name
173
+ if app.cur_fn_names[n] {
174
+ println ('${n} already declared in cur fn. skipping. (why does this happen?)' )
175
+ return
176
+ }
177
+ if n == 'layerDuplicates2' {
178
+ // app.genln('${d}')
179
+ println ('=================' )
180
+ print_backtrace ()
181
+ println ('1111111111111111111111' )
182
+ }
183
+ app.gen (n)
184
+ app.cur_fn_names[n] = true
179
185
}
180
- app.gen (n)
181
186
app.gen (' := ' )
182
- app.cur_fn_names[n] = true
183
187
mut kind := 'int'
184
188
if spec.values.len == 0 {
185
- // app.genln('NO SPEC VALUES')
186
- // `var x int` declaration without initialization
187
189
app.force_upper = true
188
190
app.gen_zero_value (spec.typ)
189
191
continue
190
192
}
191
- value := spec.values[0 ]
192
- match value {
193
- BasicLit {
194
- kind = go2v_type (value.kind.to_lower ())
195
- if kind != 'int' {
196
- app.gen ('${kind} (' )
193
+ mut needs_cast := false
194
+ for idx in 0 .. spec.values.len {
195
+ if idx > 0 {
196
+ app.gen (',' )
197
+ }
198
+ value := spec.values[idx]
199
+ match value {
200
+ BasicLit {
201
+ kind = go2v_type (value.kind.to_lower ())
202
+ if kind != 'int' && kind != 'string'
203
+ && value.kind.to_lower () != 'char' {
204
+ needs_cast = true
205
+ }
206
+ if needs_cast {
207
+ app.gen ('${kind} (' )
208
+ }
197
209
}
210
+ else {}
198
211
}
199
- else {}
200
- }
201
- app.expr (spec.values[ 0 ] )
202
- if kind != 'int' {
203
- app. gen ( ')' )
212
+ app. expr (spec.values[idx])
213
+ if needs_cast {
214
+ app.gen ( ')' )
215
+ }
216
+ needs_cast = false
204
217
}
205
218
}
206
219
else {
0 commit comments