| ... | ... | @@ -2455,9 +2455,16 @@ fn arrayType(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.Index) !Z |
| 2455 | 2455 | const astgen = gz.astgen; |
| 2456 | 2456 | const tree = &astgen.file.tree; |
| 2457 | 2457 | const node_datas = tree.nodes.items(.data); |
| 2458 | const node_tags = tree.nodes.items(.tag); |
| 2459 | const main_tokens = tree.nodes.items(.main_token); |
| 2458 | 2460 | |
| 2459 | | // TODO check for [_]T |
| 2460 | | const len = try expr(gz, scope, .{ .ty = .usize_type }, node_datas[node].lhs); |
| 2461 | const len_node = node_datas[node].lhs; |
| 2462 | if (node_tags[len_node] == .identifier and |
| 2463 | mem.eql(u8, tree.tokenSlice(main_tokens[len_node]), "_")) |
| 2464 | { |
| 2465 | return astgen.failNode(len_node, "unable to infer array size", .{}); |
| 2466 | } |
| 2467 | const len = try expr(gz, scope, .{ .ty = .usize_type }, len_node); |
| 2461 | 2468 | const elem_type = try typeExpr(gz, scope, node_datas[node].rhs); |
| 2462 | 2469 | |
| 2463 | 2470 | const result = try gz.addBin(.array_type, len, elem_type); |
| ... | ... | @@ -2468,9 +2475,17 @@ fn arrayTypeSentinel(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: ast.Node.I |
| 2468 | 2475 | const astgen = gz.astgen; |
| 2469 | 2476 | const tree = &astgen.file.tree; |
| 2470 | 2477 | const node_datas = tree.nodes.items(.data); |
| 2478 | const node_tags = tree.nodes.items(.tag); |
| 2479 | const main_tokens = tree.nodes.items(.main_token); |
| 2471 | 2480 | const extra = tree.extraData(node_datas[node].rhs, ast.Node.ArrayTypeSentinel); |
| 2472 | 2481 | |
| 2473 | | const len = try expr(gz, scope, .{ .ty = .usize_type }, node_datas[node].lhs); |
| 2482 | const len_node = node_datas[node].lhs; |
| 2483 | if (node_tags[len_node] == .identifier and |
| 2484 | mem.eql(u8, tree.tokenSlice(main_tokens[len_node]), "_")) |
| 2485 | { |
| 2486 | return astgen.failNode(len_node, "unable to infer array size", .{}); |
| 2487 | } |
| 2488 | const len = try expr(gz, scope, .{ .ty = .usize_type }, len_node); |
| 2474 | 2489 | const elem_type = try typeExpr(gz, scope, extra.elem_type); |
| 2475 | 2490 | const sentinel = try expr(gz, scope, .{ .ty = elem_type }, extra.sentinel); |
| 2476 | 2491 | |