parent
							
								
									dc948e18af
								
							
						
					
					
						commit
						1d28c4de2a
					
				|  | @ -1337,3 +1337,9 @@ fn test_array_of_multi_map() { | |||
| 	assert nums.odds == [3, 5, 7] | ||||
| 	assert nums.evens == [2, 6, 10] | ||||
| } | ||||
| 
 | ||||
| fn test_multi_fixed_array_with_default_init() { | ||||
| 	a := [3][3]int{init: [3]int{init: 10}} | ||||
| 	println(a) | ||||
| 	assert a == [[10, 10, 10]!, [10, 10, 10]!, [10, 10, 10]!]! | ||||
| } | ||||
|  |  | |||
|  | @ -2768,6 +2768,9 @@ pub fn (mut c Checker) array_init(mut array_init ast.ArrayInit) table.Type { | |||
| 			1) | ||||
| 		array_type := table.new_type(idx) | ||||
| 		array_init.typ = array_type | ||||
| 		if array_init.has_default { | ||||
| 			c.expr(array_init.default_expr) | ||||
| 		} | ||||
| 	} | ||||
| 	return array_init.typ | ||||
| } | ||||
|  |  | |||
|  | @ -35,6 +35,13 @@ fn (mut g Gen) array_init(it ast.ArrayInit) { | |||
| 					g.write(', ') | ||||
| 				} | ||||
| 			} | ||||
| 		} else if it.has_default { | ||||
| 			g.expr(it.default_expr) | ||||
| 			info := type_sym.info as table.ArrayFixed | ||||
| 			for _ in 1 .. info.size { | ||||
| 				g.write(', ') | ||||
| 				g.expr(it.default_expr) | ||||
| 			} | ||||
| 		} else { | ||||
| 			g.write('0') | ||||
| 		} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue