checker: ensure array init matches the array's type (#7118)
							parent
							
								
									215a76a715
								
							
						
					
					
						commit
						6a47deb3f8
					
				|  | @ -2317,7 +2317,10 @@ pub fn (mut c Checker) array_init(mut array_init ast.ArrayInit) table.Type { | |||
| 		} | ||||
| 		sym := c.table.get_type_symbol(array_init.elem_type) | ||||
| 		if array_init.has_default { | ||||
| 			c.expr(array_init.default_expr) | ||||
| 			default_typ := c.expr(array_init.default_expr) | ||||
| 			c.check_expected(default_typ, array_init.elem_type) or { | ||||
| 				c.error(err, array_init.default_expr.position()) | ||||
| 			} | ||||
| 		} | ||||
| 		if sym.kind == .sum_type { | ||||
| 			if array_init.has_len && !array_init.has_default { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue