authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-13 16:25:35-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-13 16:25:35-04:00
log3cbe82746489e467706c9002c0068368bb73e6d5
tree4c2f889a95c30974d2133838b3cfa0bad4e824fc
parentefb064449f4db63c1e841f6f0e434f26fcd487ab
signature Commit is signed but in an unrecognized format.

fix behavior for nested array literals

new compile error for trying to cast runtime array literals to slices

4 files changed, 158 insertions(+), 142 deletions(-)

BRANCH_TODO+6
...@@ -10,3 +10,9 @@ get an empty file compiling successfully (with no panic fn override)...@@ -10,3 +10,9 @@ get an empty file compiling successfully (with no panic fn override)
1010
11uncomment all the behavior tests11uncomment all the behavior tests
1212
13better behavior for implicit casts. for example these introduce an extra allocation/memcpy:
14 var x: [1]i32 = [_]i32{1};
15 var x = ([1]i32)([_]i32{1});
16whereas this one does not:
17 var x = [_]i32{1};
18but all 3 should be semantically identical
src/all_types.hpp+2-2
...@@ -2651,7 +2651,7 @@ struct IrInstructionContainerInitList {...@@ -2651,7 +2651,7 @@ struct IrInstructionContainerInitList {
2651 IrInstruction *elem_type;2651 IrInstruction *elem_type;
2652 size_t item_count;2652 size_t item_count;
2653 IrInstruction **items;2653 IrInstruction **items;
2654 ResultLoc *result_loc;2654 IrInstruction *result_loc;
2655};2655};
26562656
2657struct IrInstructionContainerInitFieldsField {2657struct IrInstructionContainerInitFieldsField {
...@@ -2667,7 +2667,7 @@ struct IrInstructionContainerInitFields {...@@ -2667,7 +2667,7 @@ struct IrInstructionContainerInitFields {
2667 IrInstruction *container_type;2667 IrInstruction *container_type;
2668 size_t field_count;2668 size_t field_count;
2669 IrInstructionContainerInitFieldsField *fields;2669 IrInstructionContainerInitFieldsField *fields;
2670 ResultLoc *result_loc;2670 IrInstruction *result_loc;
2671};2671};
26722672
2673struct IrInstructionUnreachable {2673struct IrInstructionUnreachable {
src/ir.cpp+53-43
...@@ -1507,7 +1507,7 @@ static IrInstruction *ir_build_un_op(IrBuilder *irb, Scope *scope, AstNode *sour...@@ -1507,7 +1507,7 @@ static IrInstruction *ir_build_un_op(IrBuilder *irb, Scope *scope, AstNode *sour
1507}1507}
15081508
1509static IrInstruction *ir_build_container_init_list(IrBuilder *irb, Scope *scope, AstNode *source_node,1509static IrInstruction *ir_build_container_init_list(IrBuilder *irb, Scope *scope, AstNode *source_node,
1510 IrInstruction *container_type, size_t item_count, IrInstruction **items, ResultLoc *result_loc)1510 IrInstruction *container_type, size_t item_count, IrInstruction **items, IrInstruction *result_loc)
1511{1511{
1512 IrInstructionContainerInitList *container_init_list_instruction =1512 IrInstructionContainerInitList *container_init_list_instruction =
1513 ir_build_instruction<IrInstructionContainerInitList>(irb, scope, source_node);1513 ir_build_instruction<IrInstructionContainerInitList>(irb, scope, source_node);
...@@ -1520,13 +1520,14 @@ static IrInstruction *ir_build_container_init_list(IrBuilder *irb, Scope *scope,...@@ -1520,13 +1520,14 @@ static IrInstruction *ir_build_container_init_list(IrBuilder *irb, Scope *scope,
1520 for (size_t i = 0; i < item_count; i += 1) {1520 for (size_t i = 0; i < item_count; i += 1) {
1521 ir_ref_instruction(items[i], irb->current_basic_block);1521 ir_ref_instruction(items[i], irb->current_basic_block);
1522 }1522 }
1523 if (result_loc != nullptr) ir_ref_instruction(result_loc, irb->current_basic_block);
15231524
1524 return &container_init_list_instruction->base;1525 return &container_init_list_instruction->base;
1525}1526}
15261527
1527static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scope, AstNode *source_node,1528static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scope, AstNode *source_node,
1528 IrInstruction *container_type, size_t field_count, IrInstructionContainerInitFieldsField *fields,1529 IrInstruction *container_type, size_t field_count, IrInstructionContainerInitFieldsField *fields,
1529 ResultLoc *result_loc)1530 IrInstruction *result_loc)
1530{1531{
1531 IrInstructionContainerInitFields *container_init_fields_instruction =1532 IrInstructionContainerInitFields *container_init_fields_instruction =
1532 ir_build_instruction<IrInstructionContainerInitFields>(irb, scope, source_node);1533 ir_build_instruction<IrInstructionContainerInitFields>(irb, scope, source_node);
...@@ -1539,6 +1540,7 @@ static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scop...@@ -1539,6 +1540,7 @@ static IrInstruction *ir_build_container_init_fields(IrBuilder *irb, Scope *scop
1539 for (size_t i = 0; i < field_count; i += 1) {1540 for (size_t i = 0; i < field_count; i += 1) {
1540 ir_ref_instruction(fields[i].value, irb->current_basic_block);1541 ir_ref_instruction(fields[i].value, irb->current_basic_block);
1541 }1542 }
1543 if (result_loc != nullptr) ir_ref_instruction(result_loc, irb->current_basic_block);
15421544
1543 return &container_init_fields_instruction->base;1545 return &container_init_fields_instruction->base;
1544}1546}
...@@ -5667,14 +5669,10 @@ static IrInstruction *ir_gen_prefix_op_expr(IrBuilder *irb, Scope *scope, AstNod...@@ -5667,14 +5669,10 @@ static IrInstruction *ir_gen_prefix_op_expr(IrBuilder *irb, Scope *scope, AstNod
5667}5669}
56685670
5669static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval,5671static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval,
5670 ResultLoc *result_loc)5672 ResultLoc *parent_result_loc)
5671{5673{
5672 assert(node->type == NodeTypeContainerInitExpr);5674 assert(node->type == NodeTypeContainerInitExpr);
56735675
5674 if (ir_should_inline(irb->exec, scope)) {
5675 result_loc = nullptr;
5676 }
5677
5678 AstNodeContainerInitExpr *container_init_expr = &node->data.container_init_expr;5676 AstNodeContainerInitExpr *container_init_expr = &node->data.container_init_expr;
5679 ContainerInitKind kind = container_init_expr->kind;5677 ContainerInitKind kind = container_init_expr->kind;
56805678
...@@ -5699,13 +5697,13 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A...@@ -5699,13 +5697,13 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A
5699 }5697 }
57005698
5701 IrInstruction *container_ptr = nullptr;5699 IrInstruction *container_ptr = nullptr;
5702 if (result_loc != nullptr) {5700 if (!ir_should_inline(irb->exec, scope)) {
5703 src_assert(result_loc->scope_elide == nullptr, node);5701 src_assert(parent_result_loc->scope_elide == nullptr, node);
5704 result_loc->scope_elide = create_elide_scope(irb->codegen, node, scope);5702 parent_result_loc->scope_elide = create_elide_scope(irb->codegen, node, scope);
57055703
5706 src_assert(result_loc != nullptr, node);5704 src_assert(parent_result_loc != nullptr, node);
5707 container_ptr = ir_build_resolve_result(irb, &result_loc->scope_elide->base,5705 container_ptr = ir_build_resolve_result(irb, &parent_result_loc->scope_elide->base,
5708 node, result_loc, container_type);5706 node, parent_result_loc, container_type);
5709 }5707 }
57105708
5711 size_t field_count = container_init_expr->entries.length;5709 size_t field_count = container_init_expr->entries.length;
...@@ -5720,14 +5718,14 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A...@@ -5720,14 +5718,14 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A
5720 Scope *val_scope = scope;5718 Scope *val_scope = scope;
5721 ResultLoc *child_result_loc = nullptr;5719 ResultLoc *child_result_loc = nullptr;
5722 if (container_ptr != nullptr) {5720 if (container_ptr != nullptr) {
5723 IrInstruction *field_ptr = ir_build_field_ptr(irb, &result_loc->scope_elide->base, expr_node,5721 IrInstruction *field_ptr = ir_build_field_ptr(irb, &parent_result_loc->scope_elide->base,
5724 container_ptr, name, true);5722 expr_node, container_ptr, name, true);
5725 ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1);5723 ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1);
5726 result_loc_inst->base.id = ResultLocIdInstruction;5724 result_loc_inst->base.id = ResultLocIdInstruction;
5727 result_loc_inst->base.source_instruction = field_ptr;5725 result_loc_inst->base.source_instruction = field_ptr;
5728 ir_ref_instruction(field_ptr, irb->current_basic_block);5726 ir_ref_instruction(field_ptr, irb->current_basic_block);
5729 child_result_loc = &result_loc_inst->base;5727 child_result_loc = &result_loc_inst->base;
5730 val_scope = &result_loc->scope_elide->base;5728 val_scope = &parent_result_loc->scope_elide->base;
5731 }5729 }
57325730
5733 IrInstruction *expr_value = ir_gen_node_extra(irb, expr_node, val_scope, LValNone,5731 IrInstruction *expr_value = ir_gen_node_extra(irb, expr_node, val_scope, LValNone,
...@@ -5740,9 +5738,9 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A...@@ -5740,9 +5738,9 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A
5740 fields[i].source_node = entry_node;5738 fields[i].source_node = entry_node;
5741 }5739 }
5742 IrInstruction *init_fields = ir_build_container_init_fields(irb, scope, node, container_type,5740 IrInstruction *init_fields = ir_build_container_init_fields(irb, scope, node, container_type,
5743 field_count, fields, result_loc);5741 field_count, fields, container_ptr);
57445742
5745 return ir_lval_wrap(irb, scope, init_fields, lval, result_loc);5743 return ir_lval_wrap(irb, scope, init_fields, lval, parent_result_loc);
5746 }5744 }
5747 case ContainerInitKindArray: {5745 case ContainerInitKindArray: {
5748 size_t item_count = container_init_expr->entries.length;5746 size_t item_count = container_init_expr->entries.length;
...@@ -5753,12 +5751,12 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A...@@ -5753,12 +5751,12 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A
5753 }5751 }
57545752
5755 IrInstruction *container_ptr = nullptr;5753 IrInstruction *container_ptr = nullptr;
5756 if (result_loc != nullptr) {5754 if (!ir_should_inline(irb->exec, scope)) {
5757 src_assert(result_loc->scope_elide == nullptr, node);5755 src_assert(parent_result_loc->scope_elide == nullptr, node);
5758 result_loc->scope_elide = create_elide_scope(irb->codegen, node, scope);5756 parent_result_loc->scope_elide = create_elide_scope(irb->codegen, node, scope);
57595757
5760 container_ptr = ir_build_resolve_result(irb, &result_loc->scope_elide->base,5758 container_ptr = ir_build_resolve_result(irb, &parent_result_loc->scope_elide->base,
5761 node, result_loc, container_type);5759 node, parent_result_loc, container_type);
5762 }5760 }
57635761
5764 IrInstruction **values = allocate<IrInstruction *>(item_count);5762 IrInstruction **values = allocate<IrInstruction *>(item_count);
...@@ -5768,15 +5766,16 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A...@@ -5768,15 +5766,16 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A
5768 ResultLoc *child_result_loc = nullptr;5766 ResultLoc *child_result_loc = nullptr;
5769 Scope *val_scope = scope;5767 Scope *val_scope = scope;
5770 if (container_ptr != nullptr) {5768 if (container_ptr != nullptr) {
5771 IrInstruction *elem_index = ir_build_const_usize(irb, &result_loc->scope_elide->base, expr_node, i);5769 IrInstruction *elem_index = ir_build_const_usize(irb, &parent_result_loc->scope_elide->base,
5772 IrInstruction *elem_ptr = ir_build_elem_ptr(irb, &result_loc->scope_elide->base, expr_node,5770 expr_node, i);
5773 container_ptr, elem_index, false, PtrLenSingle, true);5771 IrInstruction *elem_ptr = ir_build_elem_ptr(irb, &parent_result_loc->scope_elide->base,
5772 expr_node, container_ptr, elem_index, false, PtrLenSingle, true);
5774 ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1);5773 ResultLocInstruction *result_loc_inst = allocate<ResultLocInstruction>(1);
5775 result_loc_inst->base.id = ResultLocIdInstruction;5774 result_loc_inst->base.id = ResultLocIdInstruction;
5776 result_loc_inst->base.source_instruction = elem_ptr;5775 result_loc_inst->base.source_instruction = elem_ptr;
5777 ir_ref_instruction(elem_ptr, irb->current_basic_block);5776 ir_ref_instruction(elem_ptr, irb->current_basic_block);
5778 child_result_loc = &result_loc_inst->base;5777 child_result_loc = &result_loc_inst->base;
5779 val_scope = &result_loc->scope_elide->base;5778 val_scope = &parent_result_loc->scope_elide->base;
5780 }5779 }
57815780
5782 IrInstruction *expr_value = ir_gen_node_extra(irb, expr_node, val_scope, LValNone,5781 IrInstruction *expr_value = ir_gen_node_extra(irb, expr_node, val_scope, LValNone,
...@@ -5787,8 +5786,8 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A...@@ -5787,8 +5786,8 @@ static IrInstruction *ir_gen_container_init_expr(IrBuilder *irb, Scope *scope, A
5787 values[i] = expr_value;5786 values[i] = expr_value;
5788 }5787 }
5789 IrInstruction *init_list = ir_build_container_init_list(irb, scope, node, container_type,5788 IrInstruction *init_list = ir_build_container_init_list(irb, scope, node, container_type,
5790 item_count, values, result_loc);5789 item_count, values, container_ptr);
5791 return ir_lval_wrap(irb, scope, init_list, lval, result_loc);5790 return ir_lval_wrap(irb, scope, init_list, lval, parent_result_loc);
5792 }5791 }
5793 }5792 }
5794 zig_unreachable();5793 zig_unreachable();
...@@ -16900,6 +16899,14 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct...@@ -16900,6 +16899,14 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct
16900 }16899 }
16901 }16900 }
1690216901
16902 if (is_slice(array_type) && elem_ptr_instruction->initializing) {
16903 // we need a pointer to an element inside a slice. but we're initializing an array.
16904 // this means that the slice isn't actually pointing at anything.
16905 ir_add_error(ira, &elem_ptr_instruction->base,
16906 buf_sprintf("runtime-initialized array cannot be casted to slice type '%s'",
16907 buf_ptr(&array_type->name)));
16908 return ira->codegen->invalid_instruction;
16909 }
16903 } else {16910 } else {
16904 // runtime known element index16911 // runtime known element index
16905 switch (type_requires_comptime(ira->codegen, return_type)) {16912 switch (type_requires_comptime(ira->codegen, return_type)) {
...@@ -18729,7 +18736,8 @@ static IrInstruction *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstructionRe...@@ -18729,7 +18736,8 @@ static IrInstruction *ir_analyze_instruction_ref(IrAnalyze *ira, IrInstructionRe
18729}18736}
1873018737
18731static IrInstruction *ir_analyze_container_init_fields_union(IrAnalyze *ira, IrInstruction *instruction,18738static IrInstruction *ir_analyze_container_init_fields_union(IrAnalyze *ira, IrInstruction *instruction,
18732 ZigType *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields)18739 ZigType *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields,
18740 IrInstruction *old_result_loc)
18733{18741{
18734 Error err;18742 Error err;
18735 assert(container_type->id == ZigTypeIdUnion);18743 assert(container_type->id == ZigTypeIdUnion);
...@@ -18785,20 +18793,21 @@ static IrInstruction *ir_analyze_container_init_fields_union(IrAnalyze *ira, IrI...@@ -18785,20 +18793,21 @@ static IrInstruction *ir_analyze_container_init_fields_union(IrAnalyze *ira, IrI
18785 return result;18793 return result;
18786 }18794 }
1878718795
18788 // this instruction should not get to codegen18796 ir_assert(old_result_loc != nullptr, instruction);
18789 IrInstruction *new_instruction = ir_const(ira, instruction, container_type);18797 IrInstruction *result_loc = old_result_loc->child;
18790 // this is how we signal to EndExpr the value is not comptime known18798 if (type_is_invalid(result_loc->value.type))
18791 new_instruction->value.special = ConstValSpecialRuntime;18799 return result_loc;
18792 return new_instruction;18800 return ir_get_deref(ira, instruction, result_loc, nullptr);
18793}18801}
1879418802
18795static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruction *instruction,18803static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruction *instruction,
18796 ZigType *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields,18804 ZigType *container_type, size_t instr_field_count, IrInstructionContainerInitFieldsField *fields,
18797 ResultLoc *result_loc_pass1)18805 IrInstruction *old_result_loc)
18798{18806{
18799 Error err;18807 Error err;
18800 if (container_type->id == ZigTypeIdUnion) {18808 if (container_type->id == ZigTypeIdUnion) {
18801 return ir_analyze_container_init_fields_union(ira, instruction, container_type, instr_field_count, fields);18809 return ir_analyze_container_init_fields_union(ira, instruction, container_type, instr_field_count,
18810 fields, old_result_loc);
18802 }18811 }
18803 if (container_type->id != ZigTypeIdStruct || is_slice(container_type)) {18812 if (container_type->id != ZigTypeIdStruct || is_slice(container_type)) {
18804 ir_add_error(ira, instruction,18813 ir_add_error(ira, instruction,
...@@ -18929,9 +18938,10 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc...@@ -18929,9 +18938,10 @@ static IrInstruction *ir_analyze_container_init_fields(IrAnalyze *ira, IrInstruc
18929 return ira->codegen->invalid_instruction;18938 return ira->codegen->invalid_instruction;
18930 }18939 }
1893118940
18932 IrInstruction *result_loc = ir_resolve_result(ira, instruction, result_loc_pass1,18941
18933 container_type, nullptr);18942 ir_assert(old_result_loc != nullptr, instruction);
18934 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc))18943 IrInstruction *result_loc = old_result_loc->child;
18944 if (type_is_invalid(result_loc->value.type))
18935 return result_loc;18945 return result_loc;
18936 return ir_get_deref(ira, instruction, result_loc, nullptr);18946 return ir_get_deref(ira, instruction, result_loc, nullptr);
18937}18947}
...@@ -19039,9 +19049,9 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira,...@@ -19039,9 +19049,9 @@ static IrInstruction *ir_analyze_instruction_container_init_list(IrAnalyze *ira,
19039 return ira->codegen->invalid_instruction;19049 return ira->codegen->invalid_instruction;
19040 }19050 }
1904119051
19042 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base, instruction->result_loc,19052 ir_assert(instruction->result_loc != nullptr, &instruction->base);
19043 fixed_size_array_type, nullptr);19053 IrInstruction *result_loc = instruction->result_loc->child;
19044 if (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc))19054 if (type_is_invalid(result_loc->value.type))
19045 return result_loc;19055 return result_loc;
19046 return ir_get_deref(ira, &instruction->base, result_loc, nullptr);19056 return ir_get_deref(ira, &instruction->base, result_loc, nullptr);
19047 } else if (container_type->id == ZigTypeIdVoid) {19057 } else if (container_type->id == ZigTypeIdVoid) {
test/stage1/behavior/array.zig+97-97
...@@ -174,103 +174,103 @@ fn plusOne(x: u32) u32 {...@@ -174,103 +174,103 @@ fn plusOne(x: u32) u32 {
174174
175test "runtime initialize array elem and then implicit cast to slice" {175test "runtime initialize array elem and then implicit cast to slice" {
176 var two: i32 = 2;176 var two: i32 = 2;
177 const x: []const i32 = [_]i32{two};177 const x: []const i32 = [_]i32{two};
178 expect(x[0] == 2);178 expect(x[0] == 2);
179}179}
180180
181//test "array literal as argument to function" {181test "array literal as argument to function" {
182// const S = struct {182 const S = struct {
183// fn entry(two: i32) void {183 fn entry(two: i32) void {
184// foo([_]i32{184 foo([_]i32{
185// 1,185 1,
186// 2,186 2,
187// 3,187 3,
188// });188 });
189// foo([_]i32{189 foo([_]i32{
190// 1,190 1,
191// two,191 two,
192// 3,192 3,
193// });193 });
194// foo2(true, [_]i32{194 foo2(true, [_]i32{
195// 1,195 1,
196// 2,196 2,
197// 3,197 3,
198// });198 });
199// foo2(true, [_]i32{199 foo2(true, [_]i32{
200// 1,200 1,
201// two,201 two,
202// 3,202 3,
203// });203 });
204// }204 }
205// fn foo(x: []const i32) void {205 fn foo(x: []const i32) void {
206// expect(x[0] == 1);206 expect(x[0] == 1);
207// expect(x[1] == 2);207 expect(x[1] == 2);
208// expect(x[2] == 3);208 expect(x[2] == 3);
209// }209 }
210// fn foo2(trash: bool, x: []const i32) void {210 fn foo2(trash: bool, x: []const i32) void {
211// expect(trash);211 expect(trash);
212// expect(x[0] == 1);212 expect(x[0] == 1);
213// expect(x[1] == 2);213 expect(x[1] == 2);
214// expect(x[2] == 3);214 expect(x[2] == 3);
215// }215 }
216// };216 };
217// S.entry(2);217 S.entry(2);
218// comptime S.entry(2);218 comptime S.entry(2);
219//}219}
220220
221//test "double nested array to const slice cast in array literal" {221test "double nested array to const slice cast in array literal" {
222// const S = struct {222 const S = struct {
223// fn entry(two: i32) void {223 fn entry(two: i32) void {
224// const cases = [_][]const []const i32{224 const cases = [_][]const []const i32{
225// [_][]const i32{[_]i32{1}},225 &[_][]const i32{&[_]i32{1}},
226// [_][]const i32{[_]i32{ 2, 3 }},226 &[_][]const i32{&[_]i32{ 2, 3 }},
227// [_][]const i32{227 &[_][]const i32{
228// [_]i32{4},228 &[_]i32{4},
229// [_]i32{ 5, 6, 7 },229 &[_]i32{ 5, 6, 7 },
230// },230 },
231// };231 };
232// check(cases);232 check(cases);
233//233
234// const cases2 = [_][]const i32{234 const cases2 = [_][]const i32{
235// [_]i32{1},235 &[_]i32{1},
236// [_]i32{ two, 3 },236 &[_]i32{ two, 3 },
237// };237 };
238// expect(cases2.len == 2);238 expect(cases2.len == 2);
239// expect(cases2[0].len == 1);239 expect(cases2[0].len == 1);
240// expect(cases2[0][0] == 1);240 expect(cases2[0][0] == 1);
241// expect(cases2[1].len == 2);241 expect(cases2[1].len == 2);
242// expect(cases2[1][0] == 2);242 expect(cases2[1][0] == 2);
243// expect(cases2[1][1] == 3);243 expect(cases2[1][1] == 3);
244//244
245// const cases3 = [_][]const []const i32{245 const cases3 = [_][]const []const i32{
246// [_][]const i32{[_]i32{1}},246 &[_][]const i32{&[_]i32{1}},
247// [_][]const i32{[_]i32{ two, 3 }},247 &[_][]const i32{&[_]i32{ two, 3 }},
248// [_][]const i32{248 &[_][]const i32{
249// [_]i32{4},249 &[_]i32{4},
250// [_]i32{ 5, 6, 7 },250 &[_]i32{ 5, 6, 7 },
251// },251 },
252// };252 };
253// check(cases3);253 check(cases3);
254// }254 }
255//255
256// fn check(cases: []const []const []const i32) void {256 fn check(cases: []const []const []const i32) void {
257// expect(cases.len == 3);257 expect(cases.len == 3);
258// expect(cases[0].len == 1);258 expect(cases[0].len == 1);
259// expect(cases[0][0].len == 1);259 expect(cases[0][0].len == 1);
260// expect(cases[0][0][0] == 1);260 expect(cases[0][0][0] == 1);
261// expect(cases[1].len == 1);261 expect(cases[1].len == 1);
262// expect(cases[1][0].len == 2);262 expect(cases[1][0].len == 2);
263// expect(cases[1][0][0] == 2);263 expect(cases[1][0][0] == 2);
264// expect(cases[1][0][1] == 3);264 expect(cases[1][0][1] == 3);
265// expect(cases[2].len == 2);265 expect(cases[2].len == 2);
266// expect(cases[2][0].len == 1);266 expect(cases[2][0].len == 1);
267// expect(cases[2][0][0] == 4);267 expect(cases[2][0][0] == 4);
268// expect(cases[2][1].len == 3);268 expect(cases[2][1].len == 3);
269// expect(cases[2][1][0] == 5);269 expect(cases[2][1][0] == 5);
270// expect(cases[2][1][1] == 6);270 expect(cases[2][1][1] == 6);
271// expect(cases[2][1][2] == 7);271 expect(cases[2][1][2] == 7);
272// }272 }
273// };273 };
274// S.entry(2);274 S.entry(2);
275// comptime S.entry(2);275 comptime S.entry(2);
276//}276}