authorgravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2018-06-30 20:50:09+02:00
committergravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2018-06-30 20:50:09+02:00
logecd5e60be9cab03449e0d40a770c5a0c5582198d
tree628535bff4dfdaf272b337c4dd4493c2081c13ba
parent01bd5c46e177ae59f72197063c374e845eea3ff3

Expanded the list of operators that catch undefined values at comptime


2 files changed, 523 insertions(+), 31 deletions(-)

src/ir.cpp+103-31
...@@ -10773,10 +10773,15 @@ static TypeTableEntry *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp...@@ -10773,10 +10773,15 @@ static TypeTableEntry *ir_analyze_bin_op_bool(IrAnalyze *ira, IrInstructionBinOp
10773 if (casted_op2 == ira->codegen->invalid_instruction)10773 if (casted_op2 == ira->codegen->invalid_instruction)
10774 return ira->codegen->builtin_types.entry_invalid;10774 return ira->codegen->builtin_types.entry_invalid;
1077510775
10776 ConstExprValue *op1_val = &casted_op1->value;10776 if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) {
10777 ConstExprValue *op2_val = &casted_op2->value;
10778 if (op1_val->special != ConstValSpecialRuntime && op2_val->special != ConstValSpecialRuntime) {
10779 ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base);10777 ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base);
10778 ConstExprValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad);
10779 if (op1_val == nullptr)
10780 return ira->codegen->builtin_types.entry_invalid;
10781
10782 ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad);
10783 if (op2_val == nullptr)
10784 return ira->codegen->builtin_types.entry_invalid;
1078010785
10781 assert(casted_op1->value.type->id == TypeTableEntryIdBool);10786 assert(casted_op1->value.type->id == TypeTableEntryIdBool);
10782 assert(casted_op2->value.type->id == TypeTableEntryIdBool);10787 assert(casted_op2->value.type->id == TypeTableEntryIdBool);
...@@ -10926,9 +10931,14 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp...@@ -10926,9 +10931,14 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
10926 }10931 }
10927 }10932 }
1092810933
10929 ConstExprValue *op1_val = &op1->value;10934 if (instr_is_comptime(op1) && instr_is_comptime(op2)) {
10930 ConstExprValue *op2_val = &op2->value;10935 ConstExprValue *op1_val = ir_resolve_const(ira, op1, UndefBad);
10931 if (value_is_comptime(op1_val) && value_is_comptime(op2_val)) {10936 if (op1_val == nullptr)
10937 return ira->codegen->builtin_types.entry_invalid;
10938 ConstExprValue *op2_val = ir_resolve_const(ira, op2, UndefBad);
10939 if (op2_val == nullptr)
10940 return ira->codegen->builtin_types.entry_invalid;
10941
10932 bool answer;10942 bool answer;
10933 bool are_equal = op1_val->data.x_err_set->value == op2_val->data.x_err_set->value;10943 bool are_equal = op1_val->data.x_err_set->value == op2_val->data.x_err_set->value;
10934 if (op_id == IrBinOpCmpEq) {10944 if (op_id == IrBinOpCmpEq) {
...@@ -11017,10 +11027,15 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp...@@ -11017,10 +11027,15 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
11017 if (casted_op2 == ira->codegen->invalid_instruction)11027 if (casted_op2 == ira->codegen->invalid_instruction)
11018 return ira->codegen->builtin_types.entry_invalid;11028 return ira->codegen->builtin_types.entry_invalid;
1101911029
11020 ConstExprValue *op1_val = &casted_op1->value;
11021 ConstExprValue *op2_val = &casted_op2->value;
11022 bool one_possible_value = !type_requires_comptime(resolved_type) && !type_has_bits(resolved_type);11030 bool one_possible_value = !type_requires_comptime(resolved_type) && !type_has_bits(resolved_type);
11023 if (one_possible_value || (value_is_comptime(op1_val) && value_is_comptime(op2_val))) {11031 if (one_possible_value || (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2))) {
11032 ConstExprValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad);
11033 if (op1_val == nullptr)
11034 return ira->codegen->builtin_types.entry_invalid;
11035 ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad);
11036 if (op2_val == nullptr)
11037 return ira->codegen->builtin_types.entry_invalid;
11038
11024 bool answer;11039 bool answer;
11025 if (resolved_type->id == TypeTableEntryIdComptimeFloat || resolved_type->id == TypeTableEntryIdFloat) {11040 if (resolved_type->id == TypeTableEntryIdComptimeFloat || resolved_type->id == TypeTableEntryIdFloat) {
11026 Cmp cmp_result = float_cmp(op1_val, op2_val);11041 Cmp cmp_result = float_cmp(op1_val, op2_val);
...@@ -11048,11 +11063,17 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp...@@ -11048,11 +11063,17 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
11048 if (resolved_type->id == TypeTableEntryIdInt && !resolved_type->data.integral.is_signed) {11063 if (resolved_type->id == TypeTableEntryIdInt && !resolved_type->data.integral.is_signed) {
11049 ConstExprValue *known_left_val;11064 ConstExprValue *known_left_val;
11050 IrBinOp flipped_op_id;11065 IrBinOp flipped_op_id;
11051 if (value_is_comptime(op1_val)) {11066 if (instr_is_comptime(casted_op1)) {
11052 known_left_val = op1_val;11067 known_left_val = ir_resolve_const(ira, casted_op1, UndefBad);
11068 if (known_left_val == nullptr)
11069 return ira->codegen->builtin_types.entry_invalid;
11070
11053 flipped_op_id = op_id;11071 flipped_op_id = op_id;
11054 } else if (value_is_comptime(op2_val)) {11072 } else if (instr_is_comptime(casted_op2)) {
11055 known_left_val = op2_val;11073 known_left_val = ir_resolve_const(ira, casted_op2, UndefBad);
11074 if (known_left_val == nullptr)
11075 return ira->codegen->builtin_types.entry_invalid;
11076
11056 if (op_id == IrBinOpCmpLessThan) {11077 if (op_id == IrBinOpCmpLessThan) {
11057 flipped_op_id = IrBinOpCmpGreaterThan;11078 flipped_op_id = IrBinOpCmpGreaterThan;
11058 } else if (op_id == IrBinOpCmpGreaterThan) {11079 } else if (op_id == IrBinOpCmpGreaterThan) {
...@@ -11304,8 +11325,14 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *...@@ -11304,8 +11325,14 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *
11304 }11325 }
1130511326
11306 if (instr_is_comptime(op1) && instr_is_comptime(casted_op2)) {11327 if (instr_is_comptime(op1) && instr_is_comptime(casted_op2)) {
11307 ConstExprValue *op1_val = &op1->value;11328 ConstExprValue *op1_val = ir_resolve_const(ira, op1, UndefBad);
11308 ConstExprValue *op2_val = &casted_op2->value;11329 if (op1_val == nullptr)
11330 return ira->codegen->builtin_types.entry_invalid;
11331
11332 ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad);
11333 if (op2_val == nullptr)
11334 return ira->codegen->builtin_types.entry_invalid;
11335
11309 IrInstruction *result_instruction = ir_get_const(ira, &bin_op_instruction->base);11336 IrInstruction *result_instruction = ir_get_const(ira, &bin_op_instruction->base);
11310 ir_link_new_instruction(result_instruction, &bin_op_instruction->base);11337 ir_link_new_instruction(result_instruction, &bin_op_instruction->base);
11311 ConstExprValue *out_val = &result_instruction->value;11338 ConstExprValue *out_val = &result_instruction->value;
...@@ -11384,7 +11411,15 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp...@@ -11384,7 +11411,15 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
11384 if (is_signed_div) {11411 if (is_signed_div) {
11385 bool ok = false;11412 bool ok = false;
11386 if (instr_is_comptime(op1) && instr_is_comptime(op2)) {11413 if (instr_is_comptime(op1) && instr_is_comptime(op2)) {
11387 if (bigint_cmp_zero(&op2->value.data.x_bigint) == CmpEQ) {11414 ConstExprValue *op1_val = ir_resolve_const(ira, op1, UndefBad);
11415 if (op1_val == nullptr)
11416 return ira->codegen->builtin_types.entry_invalid;
11417
11418 ConstExprValue *op2_val = ir_resolve_const(ira, op2, UndefBad);
11419 if (op2_val == nullptr)
11420 return ira->codegen->builtin_types.entry_invalid;
11421
11422 if (bigint_cmp_zero(&op2_val->data.x_bigint) == CmpEQ) {
11388 // the division by zero error will be caught later, but we don't have a11423 // the division by zero error will be caught later, but we don't have a
11389 // division function ambiguity problem.11424 // division function ambiguity problem.
11390 op_id = IrBinOpDivTrunc;11425 op_id = IrBinOpDivTrunc;
...@@ -11392,8 +11427,8 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp...@@ -11392,8 +11427,8 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
11392 } else {11427 } else {
11393 BigInt trunc_result;11428 BigInt trunc_result;
11394 BigInt floor_result;11429 BigInt floor_result;
11395 bigint_div_trunc(&trunc_result, &op1->value.data.x_bigint, &op2->value.data.x_bigint);11430 bigint_div_trunc(&trunc_result, &op1_val->data.x_bigint, &op2_val->data.x_bigint);
11396 bigint_div_floor(&floor_result, &op1->value.data.x_bigint, &op2->value.data.x_bigint);11431 bigint_div_floor(&floor_result, &op1_val->data.x_bigint, &op2_val->data.x_bigint);
11397 if (bigint_cmp(&trunc_result, &floor_result) == CmpEQ) {11432 if (bigint_cmp(&trunc_result, &floor_result) == CmpEQ) {
11398 ok = true;11433 ok = true;
11399 op_id = IrBinOpDivTrunc;11434 op_id = IrBinOpDivTrunc;
...@@ -11414,7 +11449,15 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp...@@ -11414,7 +11449,15 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
11414 if (is_signed_div && (is_int || is_float)) {11449 if (is_signed_div && (is_int || is_float)) {
11415 bool ok = false;11450 bool ok = false;
11416 if (instr_is_comptime(op1) && instr_is_comptime(op2)) {11451 if (instr_is_comptime(op1) && instr_is_comptime(op2)) {
11452 ConstExprValue *op1_val = ir_resolve_const(ira, op1, UndefBad);
11453 if (op1_val == nullptr)
11454 return ira->codegen->builtin_types.entry_invalid;
11455
11417 if (is_int) {11456 if (is_int) {
11457 ConstExprValue *op2_val = ir_resolve_const(ira, op2, UndefBad);
11458 if (op2_val == nullptr)
11459 return ira->codegen->builtin_types.entry_invalid;
11460
11418 if (bigint_cmp_zero(&op2->value.data.x_bigint) == CmpEQ) {11461 if (bigint_cmp_zero(&op2->value.data.x_bigint) == CmpEQ) {
11419 // the division by zero error will be caught later, but we don't11462 // the division by zero error will be caught later, but we don't
11420 // have a remainder function ambiguity problem11463 // have a remainder function ambiguity problem
...@@ -11422,14 +11465,19 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp...@@ -11422,14 +11465,19 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
11422 } else {11465 } else {
11423 BigInt rem_result;11466 BigInt rem_result;
11424 BigInt mod_result;11467 BigInt mod_result;
11425 bigint_rem(&rem_result, &op1->value.data.x_bigint, &op2->value.data.x_bigint);11468 bigint_rem(&rem_result, &op1_val->data.x_bigint, &op2_val->data.x_bigint);
11426 bigint_mod(&mod_result, &op1->value.data.x_bigint, &op2->value.data.x_bigint);11469 bigint_mod(&mod_result, &op1_val->data.x_bigint, &op2_val->data.x_bigint);
11427 ok = bigint_cmp(&rem_result, &mod_result) == CmpEQ;11470 ok = bigint_cmp(&rem_result, &mod_result) == CmpEQ;
11428 }11471 }
11429 } else {11472 } else {
11430 IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, resolved_type);11473 IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, resolved_type);
11431 if (casted_op2 == ira->codegen->invalid_instruction)11474 if (casted_op2 == ira->codegen->invalid_instruction)
11432 return ira->codegen->builtin_types.entry_invalid;11475 return ira->codegen->builtin_types.entry_invalid;
11476
11477 ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad);
11478 if (op2_val == nullptr)
11479 return ira->codegen->builtin_types.entry_invalid;
11480
11433 if (float_cmp_zero(&casted_op2->value) == CmpEQ) {11481 if (float_cmp_zero(&casted_op2->value) == CmpEQ) {
11434 // the division by zero error will be caught later, but we don't11482 // the division by zero error will be caught later, but we don't
11435 // have a remainder function ambiguity problem11483 // have a remainder function ambiguity problem
...@@ -11437,8 +11485,8 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp...@@ -11437,8 +11485,8 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
11437 } else {11485 } else {
11438 ConstExprValue rem_result;11486 ConstExprValue rem_result;
11439 ConstExprValue mod_result;11487 ConstExprValue mod_result;
11440 float_rem(&rem_result, &op1->value, &casted_op2->value);11488 float_rem(&rem_result, op1_val, op2_val);
11441 float_mod(&mod_result, &op1->value, &casted_op2->value);11489 float_mod(&mod_result, op1_val, op2_val);
11442 ok = float_cmp(&rem_result, &mod_result) == CmpEQ;11490 ok = float_cmp(&rem_result, &mod_result) == CmpEQ;
11443 }11491 }
11444 }11492 }
...@@ -11496,8 +11544,13 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp...@@ -11496,8 +11544,13 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
11496 return ira->codegen->builtin_types.entry_invalid;11544 return ira->codegen->builtin_types.entry_invalid;
1149711545
11498 if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) {11546 if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) {
11499 ConstExprValue *op1_val = &casted_op1->value;11547 ConstExprValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad);
11500 ConstExprValue *op2_val = &casted_op2->value;11548 if (op1_val == nullptr)
11549 return ira->codegen->builtin_types.entry_invalid;
11550 ConstExprValue *op2_val = ir_resolve_const(ira, casted_op2, UndefBad);
11551 if (op2_val == nullptr)
11552 return ira->codegen->builtin_types.entry_invalid;
11553
11501 IrInstruction *result_instruction = ir_get_const(ira, &bin_op_instruction->base);11554 IrInstruction *result_instruction = ir_get_const(ira, &bin_op_instruction->base);
11502 ir_link_new_instruction(result_instruction, &bin_op_instruction->base);11555 ir_link_new_instruction(result_instruction, &bin_op_instruction->base);
11503 ConstExprValue *out_val = &result_instruction->value;11556 ConstExprValue *out_val = &result_instruction->value;
...@@ -11672,9 +11725,16 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *...@@ -11672,9 +11725,16 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *
11672 out_val->data.x_ptr.data.base_array.array_val = out_array_val;11725 out_val->data.x_ptr.data.base_array.array_val = out_array_val;
11673 out_val->data.x_ptr.data.base_array.elem_index = 0;11726 out_val->data.x_ptr.data.base_array.elem_index = 0;
11674 }11727 }
11675 out_array_val->data.x_array.s_none.elements = create_const_vals(new_len);
1167611728
11729 if (op1_array_val->data.x_array.special == ConstArraySpecialUndef &&
11730 op2_array_val->data.x_array.special == ConstArraySpecialUndef) {
11731 out_array_val->data.x_array.special = ConstArraySpecialUndef;
11732 return result_type;
11733 }
11734
11735 out_array_val->data.x_array.s_none.elements = create_const_vals(new_len);
11677 expand_undef_array(ira->codegen, op1_array_val);11736 expand_undef_array(ira->codegen, op1_array_val);
11737 expand_undef_array(ira->codegen, op2_array_val);
1167811738
11679 size_t next_index = 0;11739 size_t next_index = 0;
11680 for (size_t i = op1_array_index; i < op1_array_end; i += 1, next_index += 1) {11740 for (size_t i = op1_array_index; i < op1_array_end; i += 1, next_index += 1) {
...@@ -11726,10 +11786,14 @@ static TypeTableEntry *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp...@@ -11726,10 +11786,14 @@ static TypeTableEntry *ir_analyze_array_mult(IrAnalyze *ira, IrInstructionBinOp
11726 }11786 }
1172711787
11728 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);11788 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
11789 if (array_val->data.x_array.special == ConstArraySpecialUndef) {
11790 out_val->data.x_array.special = ConstArraySpecialUndef;
1172911791
11730 out_val->data.x_array.s_none.elements = create_const_vals(new_array_len);11792 TypeTableEntry *child_type = array_type->data.array.child_type;
11793 return get_array_type(ira->codegen, child_type, new_array_len);
11794 }
1173111795
11732 expand_undef_array(ira->codegen, array_val);11796 out_val->data.x_array.s_none.elements = create_const_vals(new_array_len);
1173311797
11734 uint64_t i = 0;11798 uint64_t i = 0;
11735 for (uint64_t x = 0; x < mult_amt; x += 1) {11799 for (uint64_t x = 0; x < mult_amt; x += 1) {
...@@ -13056,7 +13120,11 @@ static TypeTableEntry *ir_analyze_dereference(IrAnalyze *ira, IrInstructionUnOp...@@ -13056,7 +13120,11 @@ static TypeTableEntry *ir_analyze_dereference(IrAnalyze *ira, IrInstructionUnOp
13056 // one of the ptr instructions13120 // one of the ptr instructions
1305713121
13058 if (instr_is_comptime(value)) {13122 if (instr_is_comptime(value)) {
13059 ConstExprValue *pointee = const_ptr_pointee(ira->codegen, &value->value);13123 ConstExprValue *comptime_value = ir_resolve_const(ira, value, UndefBad);
13124 if (comptime_value == nullptr)
13125 return ira->codegen->builtin_types.entry_invalid;
13126
13127 ConstExprValue *pointee = const_ptr_pointee(ira->codegen, comptime_value);
13060 if (pointee->type == child_type) {13128 if (pointee->type == child_type) {
13061 ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base);13129 ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base);
13062 copy_const_val(out_val, pointee, value->value.data.x_ptr.mut == ConstPtrMutComptimeConst);13130 copy_const_val(out_val, pointee, value->value.data.x_ptr.mut == ConstPtrMutComptimeConst);
...@@ -13173,7 +13241,7 @@ static TypeTableEntry *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *ins...@@ -13173,7 +13241,7 @@ static TypeTableEntry *ir_analyze_bin_not(IrAnalyze *ira, IrInstructionUnOp *ins
13173 if (expr_type->id == TypeTableEntryIdInt) {13241 if (expr_type->id == TypeTableEntryIdInt) {
13174 if (instr_is_comptime(value)) {13242 if (instr_is_comptime(value)) {
13175 ConstExprValue *target_const_val = ir_resolve_const(ira, value, UndefBad);13243 ConstExprValue *target_const_val = ir_resolve_const(ira, value, UndefBad);
13176 if (!target_const_val)13244 if (target_const_val == nullptr)
13177 return ira->codegen->builtin_types.entry_invalid;13245 return ira->codegen->builtin_types.entry_invalid;
1317813246
13179 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);13247 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
...@@ -17750,9 +17818,13 @@ static TypeTableEntry *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruc...@@ -17750,9 +17818,13 @@ static TypeTableEntry *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruc
17750 if (type_is_invalid(casted_value->value.type))17818 if (type_is_invalid(casted_value->value.type))
17751 return ira->codegen->builtin_types.entry_invalid;17819 return ira->codegen->builtin_types.entry_invalid;
1775217820
17753 if (casted_value->value.special != ConstValSpecialRuntime) {17821 if (instr_is_comptime(casted_value)) {
17822 ConstExprValue *value = ir_resolve_const(ira, casted_value, UndefBad);
17823 if (value == nullptr)
17824 return ira->codegen->builtin_types.entry_invalid;
17825
17754 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);17826 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
17755 out_val->data.x_bool = !casted_value->value.data.x_bool;17827 out_val->data.x_bool = !value->data.x_bool;
17756 return bool_type;17828 return bool_type;
17757 }17829 }
1775817830
test/compile_errors.zig+420
...@@ -1893,6 +1893,426 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1893,6 +1893,426 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1893 ".tmp_source.zig:1:15: error: use of undefined value",1893 ".tmp_source.zig:1:15: error: use of undefined value",
1894 );1894 );
18951895
1896 cases.add(
1897 "div on undefined value",
1898 \\comptime {
1899 \\ var a: i64 = undefined;
1900 \\ _ = a / a;
1901 \\}
1902 ,
1903 ".tmp_source.zig:3:9: error: use of undefined value",
1904 );
1905
1906 cases.add(
1907 "div assign on undefined value",
1908 \\comptime {
1909 \\ var a: i64 = undefined;
1910 \\ a /= a;
1911 \\}
1912 ,
1913 ".tmp_source.zig:3:5: error: use of undefined value",
1914 );
1915
1916 cases.add(
1917 "mod on undefined value",
1918 \\comptime {
1919 \\ var a: i64 = undefined;
1920 \\ _ = a % a;
1921 \\}
1922 ,
1923 ".tmp_source.zig:3:9: error: use of undefined value",
1924 );
1925
1926 cases.add(
1927 "mod assign on undefined value",
1928 \\comptime {
1929 \\ var a: i64 = undefined;
1930 \\ a %= a;
1931 \\}
1932 ,
1933 ".tmp_source.zig:3:5: error: use of undefined value",
1934 );
1935
1936 cases.add(
1937 "add on undefined value",
1938 \\comptime {
1939 \\ var a: i64 = undefined;
1940 \\ _ = a + a;
1941 \\}
1942 ,
1943 ".tmp_source.zig:3:9: error: use of undefined value",
1944 );
1945
1946 cases.add(
1947 "add assign on undefined value",
1948 \\comptime {
1949 \\ var a: i64 = undefined;
1950 \\ a += a;
1951 \\}
1952 ,
1953 ".tmp_source.zig:3:5: error: use of undefined value",
1954 );
1955
1956 cases.add(
1957 "add wrap on undefined value",
1958 \\comptime {
1959 \\ var a: i64 = undefined;
1960 \\ _ = a +% a;
1961 \\}
1962 ,
1963 ".tmp_source.zig:3:9: error: use of undefined value",
1964 );
1965
1966 cases.add(
1967 "add wrap assign on undefined value",
1968 \\comptime {
1969 \\ var a: i64 = undefined;
1970 \\ a +%= a;
1971 \\}
1972 ,
1973 ".tmp_source.zig:3:5: error: use of undefined value",
1974 );
1975
1976 cases.add(
1977 "sub on undefined value",
1978 \\comptime {
1979 \\ var a: i64 = undefined;
1980 \\ _ = a - a;
1981 \\}
1982 ,
1983 ".tmp_source.zig:3:9: error: use of undefined value",
1984 );
1985
1986 cases.add(
1987 "sub assign on undefined value",
1988 \\comptime {
1989 \\ var a: i64 = undefined;
1990 \\ a -= a;
1991 \\}
1992 ,
1993 ".tmp_source.zig:3:5: error: use of undefined value",
1994 );
1995
1996 cases.add(
1997 "sub wrap on undefined value",
1998 \\comptime {
1999 \\ var a: i64 = undefined;
2000 \\ _ = a -% a;
2001 \\}
2002 ,
2003 ".tmp_source.zig:3:9: error: use of undefined value",
2004 );
2005
2006 cases.add(
2007 "sub wrap assign on undefined value",
2008 \\comptime {
2009 \\ var a: i64 = undefined;
2010 \\ a -%= a;
2011 \\}
2012 ,
2013 ".tmp_source.zig:3:5: error: use of undefined value",
2014 );
2015
2016 cases.add(
2017 "mult on undefined value",
2018 \\comptime {
2019 \\ var a: i64 = undefined;
2020 \\ _ = a * a;
2021 \\}
2022 ,
2023 ".tmp_source.zig:3:9: error: use of undefined value",
2024 );
2025
2026 cases.add(
2027 "mult assign on undefined value",
2028 \\comptime {
2029 \\ var a: i64 = undefined;
2030 \\ a *= a;
2031 \\}
2032 ,
2033 ".tmp_source.zig:3:5: error: use of undefined value",
2034 );
2035
2036 cases.add(
2037 "mult wrap on undefined value",
2038 \\comptime {
2039 \\ var a: i64 = undefined;
2040 \\ _ = a *% a;
2041 \\}
2042 ,
2043 ".tmp_source.zig:3:9: error: use of undefined value",
2044 );
2045
2046 cases.add(
2047 "mult wrap assign on undefined value",
2048 \\comptime {
2049 \\ var a: i64 = undefined;
2050 \\ a *%= a;
2051 \\}
2052 ,
2053 ".tmp_source.zig:3:5: error: use of undefined value",
2054 );
2055
2056 cases.add(
2057 "shift left on undefined value",
2058 \\comptime {
2059 \\ var a: i64 = undefined;
2060 \\ _ = a << 2;
2061 \\}
2062 ,
2063 ".tmp_source.zig:3:9: error: use of undefined value",
2064 );
2065
2066 cases.add(
2067 "shift left assign on undefined value",
2068 \\comptime {
2069 \\ var a: i64 = undefined;
2070 \\ a <<= 2;
2071 \\}
2072 ,
2073 ".tmp_source.zig:3:5: error: use of undefined value",
2074 );
2075
2076 cases.add(
2077 "shift right on undefined value",
2078 \\comptime {
2079 \\ var a: i64 = undefined;
2080 \\ _ = a >> 2;
2081 \\}
2082 ,
2083 ".tmp_source.zig:3:9: error: use of undefined value",
2084 );
2085
2086 cases.add(
2087 "shift left assign on undefined value",
2088 \\comptime {
2089 \\ var a: i64 = undefined;
2090 \\ a >>= 2;
2091 \\}
2092 ,
2093 ".tmp_source.zig:3:5: error: use of undefined value",
2094 );
2095
2096 cases.add(
2097 "bin and on undefined value",
2098 \\comptime {
2099 \\ var a: i64 = undefined;
2100 \\ _ = a & a;
2101 \\}
2102 ,
2103 ".tmp_source.zig:3:9: error: use of undefined value",
2104 );
2105
2106 cases.add(
2107 "bin and assign on undefined value",
2108 \\comptime {
2109 \\ var a: i64 = undefined;
2110 \\ a &= a;
2111 \\}
2112 ,
2113 ".tmp_source.zig:3:5: error: use of undefined value",
2114 );
2115
2116 cases.add(
2117 "bin or on undefined value",
2118 \\comptime {
2119 \\ var a: i64 = undefined;
2120 \\ _ = a | a;
2121 \\}
2122 ,
2123 ".tmp_source.zig:3:9: error: use of undefined value",
2124 );
2125
2126 cases.add(
2127 "bin or assign on undefined value",
2128 \\comptime {
2129 \\ var a: i64 = undefined;
2130 \\ a |= a;
2131 \\}
2132 ,
2133 ".tmp_source.zig:3:5: error: use of undefined value",
2134 );
2135
2136 cases.add(
2137 "bin xor on undefined value",
2138 \\comptime {
2139 \\ var a: i64 = undefined;
2140 \\ _ = a ^ a;
2141 \\}
2142 ,
2143 ".tmp_source.zig:3:9: error: use of undefined value",
2144 );
2145
2146 cases.add(
2147 "bin xor assign on undefined value",
2148 \\comptime {
2149 \\ var a: i64 = undefined;
2150 \\ a ^= a;
2151 \\}
2152 ,
2153 ".tmp_source.zig:3:5: error: use of undefined value",
2154 );
2155
2156 cases.add(
2157 "equal on undefined value",
2158 \\comptime {
2159 \\ var a: i64 = undefined;
2160 \\ _ = a == a;
2161 \\}
2162 ,
2163 ".tmp_source.zig:3:9: error: use of undefined value",
2164 );
2165
2166 cases.add(
2167 "not equal on undefined value",
2168 \\comptime {
2169 \\ var a: i64 = undefined;
2170 \\ _ = a != a;
2171 \\}
2172 ,
2173 ".tmp_source.zig:3:9: error: use of undefined value",
2174 );
2175
2176 cases.add(
2177 "greater than on undefined value",
2178 \\comptime {
2179 \\ var a: i64 = undefined;
2180 \\ _ = a > a;
2181 \\}
2182 ,
2183 ".tmp_source.zig:3:9: error: use of undefined value",
2184 );
2185
2186 cases.add(
2187 "greater than equal on undefined value",
2188 \\comptime {
2189 \\ var a: i64 = undefined;
2190 \\ _ = a >= a;
2191 \\}
2192 ,
2193 ".tmp_source.zig:3:9: error: use of undefined value",
2194 );
2195
2196 cases.add(
2197 "less than on undefined value",
2198 \\comptime {
2199 \\ var a: i64 = undefined;
2200 \\ _ = a < a;
2201 \\}
2202 ,
2203 ".tmp_source.zig:3:9: error: use of undefined value",
2204 );
2205
2206 cases.add(
2207 "less than equal on undefined value",
2208 \\comptime {
2209 \\ var a: i64 = undefined;
2210 \\ _ = a <= a;
2211 \\}
2212 ,
2213 ".tmp_source.zig:3:9: error: use of undefined value",
2214 );
2215
2216 cases.add(
2217 "and on undefined value",
2218 \\comptime {
2219 \\ var a: bool = undefined;
2220 \\ _ = a and a;
2221 \\}
2222 ,
2223 ".tmp_source.zig:3:9: error: use of undefined value",
2224 );
2225
2226 cases.add(
2227 "or on undefined value",
2228 \\comptime {
2229 \\ var a: bool = undefined;
2230 \\ _ = a or a;
2231 \\}
2232 ,
2233 ".tmp_source.zig:3:9: error: use of undefined value",
2234 );
2235
2236 cases.add(
2237 "negate on undefined value",
2238 \\comptime {
2239 \\ var a: i64 = undefined;
2240 \\ _ = -a;
2241 \\}
2242 ,
2243 ".tmp_source.zig:3:10: error: use of undefined value",
2244 );
2245
2246 cases.add(
2247 "negate wrap on undefined value",
2248 \\comptime {
2249 \\ var a: i64 = undefined;
2250 \\ _ = -%a;
2251 \\}
2252 ,
2253 ".tmp_source.zig:3:11: error: use of undefined value",
2254 );
2255
2256 cases.add(
2257 "bin not on undefined value",
2258 \\comptime {
2259 \\ var a: i64 = undefined;
2260 \\ _ = ~a;
2261 \\}
2262 ,
2263 ".tmp_source.zig:3:10: error: use of undefined value",
2264 );
2265
2266 cases.add(
2267 "bool not on undefined value",
2268 \\comptime {
2269 \\ var a: bool = undefined;
2270 \\ _ = !a;
2271 \\}
2272 ,
2273 ".tmp_source.zig:3:10: error: use of undefined value",
2274 );
2275
2276 cases.add(
2277 "orelse on undefined value",
2278 \\comptime {
2279 \\ var a: ?bool = undefined;
2280 \\ _ = a orelse false;
2281 \\}
2282 ,
2283 ".tmp_source.zig:3:11: error: use of undefined value",
2284 );
2285
2286 cases.add(
2287 "catch on undefined value",
2288 \\comptime {
2289 \\ var a: error!bool = undefined;
2290 \\ _ = a catch |err| false;
2291 \\}
2292 ,
2293 ".tmp_source.zig:3:11: error: use of undefined value",
2294 );
2295
2296 cases.add(
2297 "deref on undefined value",
2298 \\comptime {
2299 \\ var a: *u8 = undefined;
2300 \\ _ = a.*;
2301 \\}
2302 ,
2303 ".tmp_source.zig:3:11: error: use of undefined value",
2304 );
2305
2306 cases.add(
2307 "unwrap on undefined value",
2308 \\comptime {
2309 \\ var a: ?u8 = undefined;
2310 \\ _ = a.?;
2311 \\}
2312 ,
2313 ".tmp_source.zig:3:11: error: use of undefined value",
2314 );
2315
1896 cases.add(2316 cases.add(
1897 "endless loop in function evaluation",2317 "endless loop in function evaluation",
1898 \\const seventh_fib_number = fibbonaci(7);2318 \\const seventh_fib_number = fibbonaci(7);