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
1077310773 if (casted_op2 == ira->codegen->invalid_instruction)
1077410774 return ira->codegen->builtin_types.entry_invalid;
1077510775
10776 ConstExprValue *op1_val = &casted_op1->value;
10777 ConstExprValue *op2_val = &casted_op2->value;
10778 if (op1_val->special != ConstValSpecialRuntime && op2_val->special != ConstValSpecialRuntime) {
10776 if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) {
1077910777 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
1078110786 assert(casted_op1->value.type->id == TypeTableEntryIdBool);
1078210787 assert(casted_op2->value.type->id == TypeTableEntryIdBool);
......@@ -10926,9 +10931,14 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
1092610931 }
1092710932 }
1092810933
10929 ConstExprValue *op1_val = &op1->value;
10930 ConstExprValue *op2_val = &op2->value;
10931 if (value_is_comptime(op1_val) && value_is_comptime(op2_val)) {
10934 if (instr_is_comptime(op1) && instr_is_comptime(op2)) {
10935 ConstExprValue *op1_val = ir_resolve_const(ira, op1, UndefBad);
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
1093210942 bool answer;
1093310943 bool are_equal = op1_val->data.x_err_set->value == op2_val->data.x_err_set->value;
1093410944 if (op_id == IrBinOpCmpEq) {
......@@ -11017,10 +11027,15 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
1101711027 if (casted_op2 == ira->codegen->invalid_instruction)
1101811028 return ira->codegen->builtin_types.entry_invalid;
1101911029
11020 ConstExprValue *op1_val = &casted_op1->value;
11021 ConstExprValue *op2_val = &casted_op2->value;
1102211030 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
1102411039 bool answer;
1102511040 if (resolved_type->id == TypeTableEntryIdComptimeFloat || resolved_type->id == TypeTableEntryIdFloat) {
1102611041 Cmp cmp_result = float_cmp(op1_val, op2_val);
......@@ -11048,11 +11063,17 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
1104811063 if (resolved_type->id == TypeTableEntryIdInt && !resolved_type->data.integral.is_signed) {
1104911064 ConstExprValue *known_left_val;
1105011065 IrBinOp flipped_op_id;
11051 if (value_is_comptime(op1_val)) {
11052 known_left_val = op1_val;
11066 if (instr_is_comptime(casted_op1)) {
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
1105311071 flipped_op_id = op_id;
11054 } else if (value_is_comptime(op2_val)) {
11055 known_left_val = op2_val;
11072 } else if (instr_is_comptime(casted_op2)) {
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
1105611077 if (op_id == IrBinOpCmpLessThan) {
1105711078 flipped_op_id = IrBinOpCmpGreaterThan;
1105811079 } else if (op_id == IrBinOpCmpGreaterThan) {
......@@ -11304,8 +11325,14 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *
1130411325 }
1130511326
1130611327 if (instr_is_comptime(op1) && instr_is_comptime(casted_op2)) {
11307 ConstExprValue *op1_val = &op1->value;
11308 ConstExprValue *op2_val = &casted_op2->value;
11328 ConstExprValue *op1_val = ir_resolve_const(ira, op1, UndefBad);
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
1130911336 IrInstruction *result_instruction = ir_get_const(ira, &bin_op_instruction->base);
1131011337 ir_link_new_instruction(result_instruction, &bin_op_instruction->base);
1131111338 ConstExprValue *out_val = &result_instruction->value;
......@@ -11384,7 +11411,15 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1138411411 if (is_signed_div) {
1138511412 bool ok = false;
1138611413 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) {
1138811423 // the division by zero error will be caught later, but we don't have a
1138911424 // division function ambiguity problem.
1139011425 op_id = IrBinOpDivTrunc;
......@@ -11392,8 +11427,8 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1139211427 } else {
1139311428 BigInt trunc_result;
1139411429 BigInt floor_result;
11395 bigint_div_trunc(&trunc_result, &op1->value.data.x_bigint, &op2->value.data.x_bigint);
11396 bigint_div_floor(&floor_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);
11431 bigint_div_floor(&floor_result, &op1_val->data.x_bigint, &op2_val->data.x_bigint);
1139711432 if (bigint_cmp(&trunc_result, &floor_result) == CmpEQ) {
1139811433 ok = true;
1139911434 op_id = IrBinOpDivTrunc;
......@@ -11414,7 +11449,15 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1141411449 if (is_signed_div && (is_int || is_float)) {
1141511450 bool ok = false;
1141611451 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
1141711456 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
1141811461 if (bigint_cmp_zero(&op2->value.data.x_bigint) == CmpEQ) {
1141911462 // the division by zero error will be caught later, but we don't
1142011463 // have a remainder function ambiguity problem
......@@ -11422,14 +11465,19 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1142211465 } else {
1142311466 BigInt rem_result;
1142411467 BigInt mod_result;
11425 bigint_rem(&rem_result, &op1->value.data.x_bigint, &op2->value.data.x_bigint);
11426 bigint_mod(&mod_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);
11469 bigint_mod(&mod_result, &op1_val->data.x_bigint, &op2_val->data.x_bigint);
1142711470 ok = bigint_cmp(&rem_result, &mod_result) == CmpEQ;
1142811471 }
1142911472 } else {
1143011473 IrInstruction *casted_op2 = ir_implicit_cast(ira, op2, resolved_type);
1143111474 if (casted_op2 == ira->codegen->invalid_instruction)
1143211475 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
1143311481 if (float_cmp_zero(&casted_op2->value) == CmpEQ) {
1143411482 // the division by zero error will be caught later, but we don't
1143511483 // have a remainder function ambiguity problem
......@@ -11437,8 +11485,8 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1143711485 } else {
1143811486 ConstExprValue rem_result;
1143911487 ConstExprValue mod_result;
11440 float_rem(&rem_result, &op1->value, &casted_op2->value);
11441 float_mod(&mod_result, &op1->value, &casted_op2->value);
11488 float_rem(&rem_result, op1_val, op2_val);
11489 float_mod(&mod_result, op1_val, op2_val);
1144211490 ok = float_cmp(&rem_result, &mod_result) == CmpEQ;
1144311491 }
1144411492 }
......@@ -11496,8 +11544,13 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1149611544 return ira->codegen->builtin_types.entry_invalid;
1149711545
1149811546 if (instr_is_comptime(casted_op1) && instr_is_comptime(casted_op2)) {
11499 ConstExprValue *op1_val = &casted_op1->value;
11500 ConstExprValue *op2_val = &casted_op2->value;
11547 ConstExprValue *op1_val = ir_resolve_const(ira, casted_op1, UndefBad);
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
1150111554 IrInstruction *result_instruction = ir_get_const(ira, &bin_op_instruction->base);
1150211555 ir_link_new_instruction(result_instruction, &bin_op_instruction->base);
1150311556 ConstExprValue *out_val = &result_instruction->value;
......@@ -11672,9 +11725,16 @@ static TypeTableEntry *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *
1167211725 out_val->data.x_ptr.data.base_array.array_val = out_array_val;
1167311726 out_val->data.x_ptr.data.base_array.elem_index = 0;
1167411727 }
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);
1167711736 expand_undef_array(ira->codegen, op1_array_val);
11737 expand_undef_array(ira->codegen, op2_array_val);
1167811738
1167911739 size_t next_index = 0;
1168011740 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
1172611786 }
1172711787
1172811788 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
1173411798 uint64_t i = 0;
1173511799 for (uint64_t x = 0; x < mult_amt; x += 1) {
......@@ -13056,7 +13120,11 @@ static TypeTableEntry *ir_analyze_dereference(IrAnalyze *ira, IrInstructionUnOp
1305613120 // one of the ptr instructions
1305713121
1305813122 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);
1306013128 if (pointee->type == child_type) {
1306113129 ConstExprValue *out_val = ir_build_const_from(ira, &un_op_instruction->base);
1306213130 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
1317313241 if (expr_type->id == TypeTableEntryIdInt) {
1317413242 if (instr_is_comptime(value)) {
1317513243 ConstExprValue *target_const_val = ir_resolve_const(ira, value, UndefBad);
13176 if (!target_const_val)
13244 if (target_const_val == nullptr)
1317713245 return ira->codegen->builtin_types.entry_invalid;
1317813246
1317913247 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
......@@ -17750,9 +17818,13 @@ static TypeTableEntry *ir_analyze_instruction_bool_not(IrAnalyze *ira, IrInstruc
1775017818 if (type_is_invalid(casted_value->value.type))
1775117819 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
1775417826 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;
1775617828 return bool_type;
1775717829 }
1775817830
test/compile_errors.zig+420
......@@ -1893,6 +1893,426 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
18931893 ".tmp_source.zig:1:15: error: use of undefined value",
18941894 );
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
18962316 cases.add(
18972317 "endless loop in function evaluation",
18982318 \\const seventh_fib_number = fibbonaci(7);