parent
							
								
									d094baf107
								
							
						
					
					
						commit
						34c89258a4
					
				|  | @ -1291,3 +1291,19 @@ fn test_array_struct_ref_index() { | |||
| 	println(coords.index(coord_1)) | ||||
| 	assert coords.index(coord_1) == 0 | ||||
| } | ||||
| 
 | ||||
| fn test_array_of_array_append() { | ||||
| 	mut x := [][]int{len: 4} | ||||
| 	println(x) // OK
 | ||||
| 	x[2] << 123 // RTE
 | ||||
| 	println(x) | ||||
| 	assert '$x' == '[[], [], [123], []]' | ||||
| } | ||||
| 
 | ||||
| fn test_array_of_map_insert() { | ||||
| 	mut x := []map[string]int{len: 4} | ||||
| 	println(x) // OK
 | ||||
| 	x[2]['123'] = 123 // RTE
 | ||||
| 	println(x) | ||||
| 	assert '$x' == "[{}, {}, {'123': 123}, {}]" | ||||
| } | ||||
|  |  | |||
|  | @ -79,6 +79,10 @@ fn (mut g Gen) array_init(it ast.ArrayInit) { | |||
| 			g.write('&($elem_type_str[]){') | ||||
| 			g.write('_SLIT("")') | ||||
| 			g.write('})') | ||||
| 		} else if it.has_len && elem_sym.kind in [.array, .map] { | ||||
| 			g.write('(voidptr)&($elem_type_str[]){') | ||||
| 			g.write(g.type_default(it.elem_type)) | ||||
| 			g.write('}[0])') | ||||
| 		} else { | ||||
| 			g.write('0)') | ||||
| 		} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue