authorgravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2018-06-05 11:14:43+02:00
committergravatar for jhc@dismail.deJimmi Holst Christensen <jhc@dismail.de> 2018-06-05 11:14:43+02:00
log02cb220faf0d527b656a3a87ec96e6738770c8e6
tree5d79c58df7d786e3fa8adc0bc382fffa3ccafe60
parente53b683bd3958a7b1c517e2391edce42b9d4e48b

Renamed "(int/float literal)" to "comptime_int/float"


13 files changed, 230 insertions(+), 216 deletions(-)

doc/langref.html.in+9-9
......@@ -4893,8 +4893,8 @@ pub const TypeId = enum {
48934893 Pointer,
48944894 Array,
48954895 Struct,
4896 FloatLiteral,
4897 IntLiteral,
4896 ComptimeFloat,
4897 ComptimeInt,
48984898 UndefinedLiteral,
48994899 NullLiteral,
49004900 Nullable,
......@@ -4927,8 +4927,8 @@ pub const TypeInfo = union(TypeId) {
49274927 Pointer: Pointer,
49284928 Array: Array,
49294929 Struct: Struct,
4930 FloatLiteral: void,
4931 IntLiteral: void,
4930 ComptimeFloat: void,
4931 ComptimeInt: void,
49324932 UndefinedLiteral: void,
49334933 NullLiteral: void,
49344934 Nullable: Nullable,
......@@ -5685,8 +5685,8 @@ pub const TypeId = enum {
56855685 Pointer,
56865686 Array,
56875687 Struct,
5688 FloatLiteral,
5689 IntLiteral,
5688 ComptimeFloat,
5689 ComptimeInt,
56905690 UndefinedLiteral,
56915691 NullLiteral,
56925692 Nullable,
......@@ -5713,10 +5713,10 @@ pub const TypeInfo = union(TypeId) {
57135713 Pointer: Pointer,
57145714 Array: Array,
57155715 Struct: Struct,
5716 FloatLiteral: void,
5717 IntLiteral: void,
5716 ComptimeFloat: void,
5717 ComptimeInt: void,
57185718 UndefinedLiteral: void,
5719 NullLiteral: void,
5719 Null: void,
57205720 Nullable: Nullable,
57215721 ErrorUnion: ErrorUnion,
57225722 ErrorSet: ErrorSet,
src/all_types.hpp+2-2
......@@ -1159,8 +1159,8 @@ enum TypeTableEntryId {
11591159 TypeTableEntryIdPointer,
11601160 TypeTableEntryIdArray,
11611161 TypeTableEntryIdStruct,
1162 TypeTableEntryIdNumLitFloat,
1163 TypeTableEntryIdNumLitInt,
1162 TypeTableEntryIdComptimeFloat,
1163 TypeTableEntryIdComptimeInt,
11641164 TypeTableEntryIdUndefLit,
11651165 TypeTableEntryIdNullLit,
11661166 TypeTableEntryIdMaybe,
src/analyze.cpp+47-47
......@@ -232,8 +232,8 @@ bool type_is_complete(TypeTableEntry *type_entry) {
232232 case TypeTableEntryIdFloat:
233233 case TypeTableEntryIdPointer:
234234 case TypeTableEntryIdArray:
235 case TypeTableEntryIdNumLitFloat:
236 case TypeTableEntryIdNumLitInt:
235 case TypeTableEntryIdComptimeFloat:
236 case TypeTableEntryIdComptimeInt:
237237 case TypeTableEntryIdUndefLit:
238238 case TypeTableEntryIdNullLit:
239239 case TypeTableEntryIdMaybe:
......@@ -268,8 +268,8 @@ bool type_has_zero_bits_known(TypeTableEntry *type_entry) {
268268 case TypeTableEntryIdFloat:
269269 case TypeTableEntryIdPointer:
270270 case TypeTableEntryIdArray:
271 case TypeTableEntryIdNumLitFloat:
272 case TypeTableEntryIdNumLitInt:
271 case TypeTableEntryIdComptimeFloat:
272 case TypeTableEntryIdComptimeInt:
273273 case TypeTableEntryIdUndefLit:
274274 case TypeTableEntryIdNullLit:
275275 case TypeTableEntryIdMaybe:
......@@ -1333,8 +1333,8 @@ static bool type_allowed_in_packed_struct(TypeTableEntry *type_entry) {
13331333 zig_unreachable();
13341334 case TypeTableEntryIdMetaType:
13351335 case TypeTableEntryIdUnreachable:
1336 case TypeTableEntryIdNumLitFloat:
1337 case TypeTableEntryIdNumLitInt:
1336 case TypeTableEntryIdComptimeFloat:
1337 case TypeTableEntryIdComptimeInt:
13381338 case TypeTableEntryIdUndefLit:
13391339 case TypeTableEntryIdNullLit:
13401340 case TypeTableEntryIdErrorUnion:
......@@ -1374,8 +1374,8 @@ static bool type_allowed_in_extern(CodeGen *g, TypeTableEntry *type_entry) {
13741374 case TypeTableEntryIdInvalid:
13751375 zig_unreachable();
13761376 case TypeTableEntryIdMetaType:
1377 case TypeTableEntryIdNumLitFloat:
1378 case TypeTableEntryIdNumLitInt:
1377 case TypeTableEntryIdComptimeFloat:
1378 case TypeTableEntryIdComptimeInt:
13791379 case TypeTableEntryIdUndefLit:
13801380 case TypeTableEntryIdNullLit:
13811381 case TypeTableEntryIdErrorUnion:
......@@ -1518,8 +1518,8 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
15181518 add_node_error(g, param_node->data.param_decl.type,
15191519 buf_sprintf("parameter of type '%s' not allowed", buf_ptr(&type_entry->name)));
15201520 return g->builtin_types.entry_invalid;
1521 case TypeTableEntryIdNumLitFloat:
1522 case TypeTableEntryIdNumLitInt:
1521 case TypeTableEntryIdComptimeFloat:
1522 case TypeTableEntryIdComptimeInt:
15231523 case TypeTableEntryIdNamespace:
15241524 case TypeTableEntryIdBlock:
15251525 case TypeTableEntryIdBoundFn:
......@@ -1607,8 +1607,8 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
16071607 buf_sprintf("return type '%s' not allowed", buf_ptr(&fn_type_id.return_type->name)));
16081608 return g->builtin_types.entry_invalid;
16091609
1610 case TypeTableEntryIdNumLitFloat:
1611 case TypeTableEntryIdNumLitInt:
1610 case TypeTableEntryIdComptimeFloat:
1611 case TypeTableEntryIdComptimeInt:
16121612 case TypeTableEntryIdNamespace:
16131613 case TypeTableEntryIdBlock:
16141614 case TypeTableEntryIdBoundFn:
......@@ -3337,8 +3337,6 @@ TypeTableEntry *validate_var_type(CodeGen *g, AstNode *source_node, TypeTableEnt
33373337 case TypeTableEntryIdInvalid:
33383338 return g->builtin_types.entry_invalid;
33393339 case TypeTableEntryIdUnreachable:
3340 case TypeTableEntryIdNumLitFloat:
3341 case TypeTableEntryIdNumLitInt:
33423340 case TypeTableEntryIdUndefLit:
33433341 case TypeTableEntryIdNullLit:
33443342 case TypeTableEntryIdBlock:
......@@ -3347,6 +3345,8 @@ TypeTableEntry *validate_var_type(CodeGen *g, AstNode *source_node, TypeTableEnt
33473345 add_node_error(g, source_node, buf_sprintf("variable of type '%s' not allowed",
33483346 buf_ptr(&type_entry->name)));
33493347 return g->builtin_types.entry_invalid;
3348 case TypeTableEntryIdComptimeFloat:
3349 case TypeTableEntryIdComptimeInt:
33503350 case TypeTableEntryIdNamespace:
33513351 case TypeTableEntryIdMetaType:
33523352 case TypeTableEntryIdVoid:
......@@ -3480,8 +3480,8 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var) {
34803480 add_node_error(g, source_node, buf_sprintf("variable initialization is unreachable"));
34813481 implicit_type = g->builtin_types.entry_invalid;
34823482 } else if ((!is_const || linkage == VarLinkageExternal) &&
3483 (implicit_type->id == TypeTableEntryIdNumLitFloat ||
3484 implicit_type->id == TypeTableEntryIdNumLitInt))
3483 (implicit_type->id == TypeTableEntryIdComptimeFloat ||
3484 implicit_type->id == TypeTableEntryIdComptimeInt))
34853485 {
34863486 add_node_error(g, source_node, buf_sprintf("unable to infer variable type"));
34873487 implicit_type = g->builtin_types.entry_invalid;
......@@ -3730,8 +3730,8 @@ static bool is_container(TypeTableEntry *type_entry) {
37303730 case TypeTableEntryIdInt:
37313731 case TypeTableEntryIdFloat:
37323732 case TypeTableEntryIdArray:
3733 case TypeTableEntryIdNumLitFloat:
3734 case TypeTableEntryIdNumLitInt:
3733 case TypeTableEntryIdComptimeFloat:
3734 case TypeTableEntryIdComptimeInt:
37353735 case TypeTableEntryIdUndefLit:
37363736 case TypeTableEntryIdNullLit:
37373737 case TypeTableEntryIdMaybe:
......@@ -3779,8 +3779,8 @@ void resolve_container_type(CodeGen *g, TypeTableEntry *type_entry) {
37793779 case TypeTableEntryIdInt:
37803780 case TypeTableEntryIdFloat:
37813781 case TypeTableEntryIdArray:
3782 case TypeTableEntryIdNumLitFloat:
3783 case TypeTableEntryIdNumLitInt:
3782 case TypeTableEntryIdComptimeFloat:
3783 case TypeTableEntryIdComptimeInt:
37843784 case TypeTableEntryIdUndefLit:
37853785 case TypeTableEntryIdNullLit:
37863786 case TypeTableEntryIdMaybe:
......@@ -4283,8 +4283,8 @@ bool handle_is_ptr(TypeTableEntry *type_entry) {
42834283 switch (type_entry->id) {
42844284 case TypeTableEntryIdInvalid:
42854285 case TypeTableEntryIdMetaType:
4286 case TypeTableEntryIdNumLitFloat:
4287 case TypeTableEntryIdNumLitInt:
4286 case TypeTableEntryIdComptimeFloat:
4287 case TypeTableEntryIdComptimeInt:
42884288 case TypeTableEntryIdUndefLit:
42894289 case TypeTableEntryIdNullLit:
42904290 case TypeTableEntryIdNamespace:
......@@ -4568,7 +4568,7 @@ static uint32_t hash_const_val(ConstExprValue *const_val) {
45684568 case TypeTableEntryIdVoid:
45694569 return (uint32_t)4149439618;
45704570 case TypeTableEntryIdInt:
4571 case TypeTableEntryIdNumLitInt:
4571 case TypeTableEntryIdComptimeInt:
45724572 {
45734573 uint32_t result = 1331471175;
45744574 for (size_t i = 0; i < const_val->data.x_bigint.digit_count; i += 1) {
......@@ -4609,7 +4609,7 @@ static uint32_t hash_const_val(ConstExprValue *const_val) {
46094609 default:
46104610 zig_unreachable();
46114611 }
4612 case TypeTableEntryIdNumLitFloat:
4612 case TypeTableEntryIdComptimeFloat:
46134613 {
46144614 float128_t f128 = bigfloat_to_f128(&const_val->data.x_bigfloat);
46154615 uint32_t ints[4];
......@@ -4754,8 +4754,8 @@ static bool can_mutate_comptime_var_state(ConstExprValue *value) {
47544754 case TypeTableEntryIdUnreachable:
47554755 case TypeTableEntryIdInt:
47564756 case TypeTableEntryIdFloat:
4757 case TypeTableEntryIdNumLitFloat:
4758 case TypeTableEntryIdNumLitInt:
4757 case TypeTableEntryIdComptimeFloat:
4758 case TypeTableEntryIdComptimeInt:
47594759 case TypeTableEntryIdUndefLit:
47604760 case TypeTableEntryIdNullLit:
47614761 case TypeTableEntryIdNamespace:
......@@ -4819,8 +4819,8 @@ static bool return_type_is_cacheable(TypeTableEntry *return_type) {
48194819 case TypeTableEntryIdUnreachable:
48204820 case TypeTableEntryIdInt:
48214821 case TypeTableEntryIdFloat:
4822 case TypeTableEntryIdNumLitFloat:
4823 case TypeTableEntryIdNumLitInt:
4822 case TypeTableEntryIdComptimeFloat:
4823 case TypeTableEntryIdComptimeInt:
48244824 case TypeTableEntryIdUndefLit:
48254825 case TypeTableEntryIdNullLit:
48264826 case TypeTableEntryIdNamespace:
......@@ -4930,8 +4930,8 @@ bool type_requires_comptime(TypeTableEntry *type_entry) {
49304930 case TypeTableEntryIdInvalid:
49314931 case TypeTableEntryIdOpaque:
49324932 zig_unreachable();
4933 case TypeTableEntryIdNumLitFloat:
4934 case TypeTableEntryIdNumLitInt:
4933 case TypeTableEntryIdComptimeFloat:
4934 case TypeTableEntryIdComptimeInt:
49354935 case TypeTableEntryIdUndefLit:
49364936 case TypeTableEntryIdNullLit:
49374937 case TypeTableEntryIdMetaType:
......@@ -5070,7 +5070,7 @@ ConstExprValue *create_const_signed(TypeTableEntry *type, int64_t x) {
50705070void init_const_float(ConstExprValue *const_val, TypeTableEntry *type, double value) {
50715071 const_val->special = ConstValSpecialStatic;
50725072 const_val->type = type;
5073 if (type->id == TypeTableEntryIdNumLitFloat) {
5073 if (type->id == TypeTableEntryIdComptimeFloat) {
50745074 bigfloat_init_64(&const_val->data.x_bigfloat, value);
50755075 } else if (type->id == TypeTableEntryIdFloat) {
50765076 switch (type->data.floating.bit_count) {
......@@ -5350,10 +5350,10 @@ bool const_values_equal(ConstExprValue *a, ConstExprValue *b) {
53505350 default:
53515351 zig_unreachable();
53525352 }
5353 case TypeTableEntryIdNumLitFloat:
5353 case TypeTableEntryIdComptimeFloat:
53545354 return bigfloat_cmp(&a->data.x_bigfloat, &b->data.x_bigfloat) == CmpEQ;
53555355 case TypeTableEntryIdInt:
5356 case TypeTableEntryIdNumLitInt:
5356 case TypeTableEntryIdComptimeInt:
53575357 return bigint_cmp(&a->data.x_bigint, &b->data.x_bigint) == CmpEQ;
53585358 case TypeTableEntryIdPointer:
53595359 case TypeTableEntryIdFn:
......@@ -5514,7 +5514,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
55145514 case TypeTableEntryIdVoid:
55155515 buf_appendf(buf, "{}");
55165516 return;
5517 case TypeTableEntryIdNumLitFloat:
5517 case TypeTableEntryIdComptimeFloat:
55185518 bigfloat_append_buf(buf, &const_val->data.x_bigfloat);
55195519 return;
55205520 case TypeTableEntryIdFloat:
......@@ -5542,7 +5542,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
55425542 default:
55435543 zig_unreachable();
55445544 }
5545 case TypeTableEntryIdNumLitInt:
5545 case TypeTableEntryIdComptimeInt:
55465546 case TypeTableEntryIdInt:
55475547 bigint_append_buf(buf, &const_val->data.x_bigint, 10);
55485548 return;
......@@ -5761,8 +5761,8 @@ uint32_t type_id_hash(TypeId x) {
57615761 case TypeTableEntryIdUnreachable:
57625762 case TypeTableEntryIdFloat:
57635763 case TypeTableEntryIdStruct:
5764 case TypeTableEntryIdNumLitFloat:
5765 case TypeTableEntryIdNumLitInt:
5764 case TypeTableEntryIdComptimeFloat:
5765 case TypeTableEntryIdComptimeInt:
57665766 case TypeTableEntryIdUndefLit:
57675767 case TypeTableEntryIdNullLit:
57685768 case TypeTableEntryIdMaybe:
......@@ -5807,8 +5807,8 @@ bool type_id_eql(TypeId a, TypeId b) {
58075807 case TypeTableEntryIdUnreachable:
58085808 case TypeTableEntryIdFloat:
58095809 case TypeTableEntryIdStruct:
5810 case TypeTableEntryIdNumLitFloat:
5811 case TypeTableEntryIdNumLitInt:
5810 case TypeTableEntryIdComptimeFloat:
5811 case TypeTableEntryIdComptimeInt:
58125812 case TypeTableEntryIdUndefLit:
58135813 case TypeTableEntryIdNullLit:
58145814 case TypeTableEntryIdMaybe:
......@@ -5929,8 +5929,8 @@ static const TypeTableEntryId all_type_ids[] = {
59295929 TypeTableEntryIdPointer,
59305930 TypeTableEntryIdArray,
59315931 TypeTableEntryIdStruct,
5932 TypeTableEntryIdNumLitFloat,
5933 TypeTableEntryIdNumLitInt,
5932 TypeTableEntryIdComptimeFloat,
5933 TypeTableEntryIdComptimeInt,
59345934 TypeTableEntryIdUndefLit,
59355935 TypeTableEntryIdNullLit,
59365936 TypeTableEntryIdMaybe,
......@@ -5980,9 +5980,9 @@ size_t type_id_index(TypeTableEntry *entry) {
59805980 if (entry->data.structure.is_slice)
59815981 return 25;
59825982 return 8;
5983 case TypeTableEntryIdNumLitFloat:
5983 case TypeTableEntryIdComptimeFloat:
59845984 return 9;
5985 case TypeTableEntryIdNumLitInt:
5985 case TypeTableEntryIdComptimeInt:
59865986 return 10;
59875987 case TypeTableEntryIdUndefLit:
59885988 return 11;
......@@ -6038,10 +6038,10 @@ const char *type_id_name(TypeTableEntryId id) {
60386038 return "Array";
60396039 case TypeTableEntryIdStruct:
60406040 return "Struct";
6041 case TypeTableEntryIdNumLitFloat:
6042 return "FloatLiteral";
6043 case TypeTableEntryIdNumLitInt:
6044 return "IntLiteral";
6041 case TypeTableEntryIdComptimeFloat:
6042 return "ComptimeFloat";
6043 case TypeTableEntryIdComptimeInt:
6044 return "ComptimeInt";
60456045 case TypeTableEntryIdUndefLit:
60466046 return "UndefinedLiteral";
60476047 case TypeTableEntryIdNullLit:
src/codegen.cpp+20-18
......@@ -4916,8 +4916,8 @@ static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, Con
49164916 case TypeTableEntryIdInvalid:
49174917 case TypeTableEntryIdMetaType:
49184918 case TypeTableEntryIdUnreachable:
4919 case TypeTableEntryIdNumLitFloat:
4920 case TypeTableEntryIdNumLitInt:
4919 case TypeTableEntryIdComptimeFloat:
4920 case TypeTableEntryIdComptimeInt:
49214921 case TypeTableEntryIdUndefLit:
49224922 case TypeTableEntryIdNullLit:
49234923 case TypeTableEntryIdErrorUnion:
......@@ -5362,8 +5362,8 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const c
53625362 case TypeTableEntryIdInvalid:
53635363 case TypeTableEntryIdMetaType:
53645364 case TypeTableEntryIdUnreachable:
5365 case TypeTableEntryIdNumLitFloat:
5366 case TypeTableEntryIdNumLitInt:
5365 case TypeTableEntryIdComptimeFloat:
5366 case TypeTableEntryIdComptimeInt:
53675367 case TypeTableEntryIdUndefLit:
53685368 case TypeTableEntryIdNullLit:
53695369 case TypeTableEntryIdNamespace:
......@@ -5604,7 +5604,7 @@ static void do_code_gen(CodeGen *g) {
56045604 TldVar *tld_var = g->global_vars.at(i);
56055605 VariableTableEntry *var = tld_var->var;
56065606
5607 if (var->value->type->id == TypeTableEntryIdNumLitFloat) {
5607 if (var->value->type->id == TypeTableEntryIdComptimeFloat) {
56085608 // Generate debug info for it but that's it.
56095609 ConstExprValue *const_val = var->value;
56105610 assert(const_val->special != ConstValSpecialRuntime);
......@@ -5618,7 +5618,7 @@ static void do_code_gen(CodeGen *g) {
56185618 continue;
56195619 }
56205620
5621 if (var->value->type->id == TypeTableEntryIdNumLitInt) {
5621 if (var->value->type->id == TypeTableEntryIdComptimeInt) {
56225622 // Generate debug info for it but that's it.
56235623 ConstExprValue *const_val = var->value;
56245624 assert(const_val->special != ConstValSpecialRuntime);
......@@ -6012,16 +6012,18 @@ static void define_builtin_types(CodeGen *g) {
60126012 g->builtin_types.entry_block = entry;
60136013 }
60146014 {
6015 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdNumLitFloat);
6016 buf_init_from_str(&entry->name, "(float literal)");
6015 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdComptimeFloat);
6016 buf_init_from_str(&entry->name, "comptime_float");
60176017 entry->zero_bits = true;
60186018 g->builtin_types.entry_num_lit_float = entry;
6019 g->primitive_type_table.put(&entry->name, entry);
60196020 }
60206021 {
6021 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdNumLitInt);
6022 buf_init_from_str(&entry->name, "(integer literal)");
6022 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdComptimeInt);
6023 buf_init_from_str(&entry->name, "comptime_int");
60236024 entry->zero_bits = true;
60246025 g->builtin_types.entry_num_lit_int = entry;
6026 g->primitive_type_table.put(&entry->name, entry);
60256027 }
60266028 {
60276029 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdUndefLit);
......@@ -6495,8 +6497,8 @@ static void define_builtin_compile_vars(CodeGen *g) {
64956497 " Slice: Slice,\n"
64966498 " Array: Array,\n"
64976499 " Struct: Struct,\n"
6498 " FloatLiteral: void,\n"
6499 " IntLiteral: void,\n"
6500 " ComptimeFloat: void,\n"
6501 " ComptimeInt: void,\n"
65006502 " UndefinedLiteral: void,\n"
65016503 " NullLiteral: void,\n"
65026504 " Nullable: Nullable,\n"
......@@ -7070,8 +7072,8 @@ static void prepend_c_type_to_decl_list(CodeGen *g, GenH *gen_h, TypeTableEntry
70707072 switch (type_entry->id) {
70717073 case TypeTableEntryIdInvalid:
70727074 case TypeTableEntryIdMetaType:
7073 case TypeTableEntryIdNumLitFloat:
7074 case TypeTableEntryIdNumLitInt:
7075 case TypeTableEntryIdComptimeFloat:
7076 case TypeTableEntryIdComptimeInt:
70757077 case TypeTableEntryIdUndefLit:
70767078 case TypeTableEntryIdNullLit:
70777079 case TypeTableEntryIdNamespace:
......@@ -7255,8 +7257,8 @@ static void get_c_type(CodeGen *g, GenH *gen_h, TypeTableEntry *type_entry, Buf
72557257 case TypeTableEntryIdBoundFn:
72567258 case TypeTableEntryIdNamespace:
72577259 case TypeTableEntryIdBlock:
7258 case TypeTableEntryIdNumLitFloat:
7259 case TypeTableEntryIdNumLitInt:
7260 case TypeTableEntryIdComptimeFloat:
7261 case TypeTableEntryIdComptimeInt:
72607262 case TypeTableEntryIdUndefLit:
72617263 case TypeTableEntryIdNullLit:
72627264 case TypeTableEntryIdArgTuple:
......@@ -7407,8 +7409,8 @@ static void gen_h_file(CodeGen *g) {
74077409 case TypeTableEntryIdInt:
74087410 case TypeTableEntryIdFloat:
74097411 case TypeTableEntryIdPointer:
7410 case TypeTableEntryIdNumLitFloat:
7411 case TypeTableEntryIdNumLitInt:
7412 case TypeTableEntryIdComptimeFloat:
7413 case TypeTableEntryIdComptimeInt:
74127414 case TypeTableEntryIdArray:
74137415 case TypeTableEntryIdUndefLit:
74147416 case TypeTableEntryIdNullLit:
src/ir.cpp+115-115
......@@ -6945,14 +6945,14 @@ static bool ir_emit_global_runtime_side_effect(IrAnalyze *ira, IrInstruction *so
69456945}
69466946
69476947static bool const_val_fits_in_num_lit(ConstExprValue *const_val, TypeTableEntry *num_lit_type) {
6948 return ((num_lit_type->id == TypeTableEntryIdNumLitFloat &&
6949 (const_val->type->id == TypeTableEntryIdFloat || const_val->type->id == TypeTableEntryIdNumLitFloat)) ||
6950 (num_lit_type->id == TypeTableEntryIdNumLitInt &&
6951 (const_val->type->id == TypeTableEntryIdInt || const_val->type->id == TypeTableEntryIdNumLitInt)));
6948 return ((num_lit_type->id == TypeTableEntryIdComptimeFloat &&
6949 (const_val->type->id == TypeTableEntryIdFloat || const_val->type->id == TypeTableEntryIdComptimeFloat)) ||
6950 (num_lit_type->id == TypeTableEntryIdComptimeInt &&
6951 (const_val->type->id == TypeTableEntryIdInt || const_val->type->id == TypeTableEntryIdComptimeInt)));
69526952}
69536953
69546954static bool float_has_fraction(ConstExprValue *const_val) {
6955 if (const_val->type->id == TypeTableEntryIdNumLitFloat) {
6955 if (const_val->type->id == TypeTableEntryIdComptimeFloat) {
69566956 return bigfloat_has_fraction(&const_val->data.x_bigfloat);
69576957 } else if (const_val->type->id == TypeTableEntryIdFloat) {
69586958 switch (const_val->type->data.floating.bit_count) {
......@@ -6975,7 +6975,7 @@ static bool float_has_fraction(ConstExprValue *const_val) {
69756975}
69766976
69776977static void float_append_buf(Buf *buf, ConstExprValue *const_val) {
6978 if (const_val->type->id == TypeTableEntryIdNumLitFloat) {
6978 if (const_val->type->id == TypeTableEntryIdComptimeFloat) {
69796979 bigfloat_append_buf(buf, &const_val->data.x_bigfloat);
69806980 } else if (const_val->type->id == TypeTableEntryIdFloat) {
69816981 switch (const_val->type->data.floating.bit_count) {
......@@ -7010,7 +7010,7 @@ static void float_append_buf(Buf *buf, ConstExprValue *const_val) {
70107010}
70117011
70127012static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) {
7013 if (const_val->type->id == TypeTableEntryIdNumLitFloat) {
7013 if (const_val->type->id == TypeTableEntryIdComptimeFloat) {
70147014 bigint_init_bigfloat(bigint, &const_val->data.x_bigfloat);
70157015 } else if (const_val->type->id == TypeTableEntryIdFloat) {
70167016 switch (const_val->type->data.floating.bit_count) {
......@@ -7046,7 +7046,7 @@ static void float_init_bigint(BigInt *bigint, ConstExprValue *const_val) {
70467046}
70477047
70487048static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) {
7049 if (dest_val->type->id == TypeTableEntryIdNumLitFloat) {
7049 if (dest_val->type->id == TypeTableEntryIdComptimeFloat) {
70507050 bigfloat_init_bigfloat(&dest_val->data.x_bigfloat, bigfloat);
70517051 } else if (dest_val->type->id == TypeTableEntryIdFloat) {
70527052 switch (dest_val->type->data.floating.bit_count) {
......@@ -7068,7 +7068,7 @@ static void float_init_bigfloat(ConstExprValue *dest_val, BigFloat *bigfloat) {
70687068}
70697069
70707070static void float_init_f32(ConstExprValue *dest_val, float x) {
7071 if (dest_val->type->id == TypeTableEntryIdNumLitFloat) {
7071 if (dest_val->type->id == TypeTableEntryIdComptimeFloat) {
70727072 bigfloat_init_32(&dest_val->data.x_bigfloat, x);
70737073 } else if (dest_val->type->id == TypeTableEntryIdFloat) {
70747074 switch (dest_val->type->data.floating.bit_count) {
......@@ -7094,7 +7094,7 @@ static void float_init_f32(ConstExprValue *dest_val, float x) {
70947094}
70957095
70967096static void float_init_f64(ConstExprValue *dest_val, double x) {
7097 if (dest_val->type->id == TypeTableEntryIdNumLitFloat) {
7097 if (dest_val->type->id == TypeTableEntryIdComptimeFloat) {
70987098 bigfloat_init_64(&dest_val->data.x_bigfloat, x);
70997099 } else if (dest_val->type->id == TypeTableEntryIdFloat) {
71007100 switch (dest_val->type->data.floating.bit_count) {
......@@ -7120,7 +7120,7 @@ static void float_init_f64(ConstExprValue *dest_val, double x) {
71207120}
71217121
71227122static void float_init_f128(ConstExprValue *dest_val, float128_t x) {
7123 if (dest_val->type->id == TypeTableEntryIdNumLitFloat) {
7123 if (dest_val->type->id == TypeTableEntryIdComptimeFloat) {
71247124 bigfloat_init_128(&dest_val->data.x_bigfloat, x);
71257125 } else if (dest_val->type->id == TypeTableEntryIdFloat) {
71267126 switch (dest_val->type->data.floating.bit_count) {
......@@ -7150,7 +7150,7 @@ static void float_init_f128(ConstExprValue *dest_val, float128_t x) {
71507150}
71517151
71527152static void float_init_float(ConstExprValue *dest_val, ConstExprValue *src_val) {
7153 if (src_val->type->id == TypeTableEntryIdNumLitFloat) {
7153 if (src_val->type->id == TypeTableEntryIdComptimeFloat) {
71547154 float_init_bigfloat(dest_val, &src_val->data.x_bigfloat);
71557155 } else if (src_val->type->id == TypeTableEntryIdFloat) {
71567156 switch (src_val->type->data.floating.bit_count) {
......@@ -7173,7 +7173,7 @@ static void float_init_float(ConstExprValue *dest_val, ConstExprValue *src_val)
71737173
71747174static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) {
71757175 assert(op1->type == op2->type);
7176 if (op1->type->id == TypeTableEntryIdNumLitFloat) {
7176 if (op1->type->id == TypeTableEntryIdComptimeFloat) {
71777177 return bigfloat_cmp(&op1->data.x_bigfloat, &op2->data.x_bigfloat);
71787178 } else if (op1->type->id == TypeTableEntryIdFloat) {
71797179 switch (op1->type->data.floating.bit_count) {
......@@ -7210,7 +7210,7 @@ static Cmp float_cmp(ConstExprValue *op1, ConstExprValue *op2) {
72107210}
72117211
72127212static Cmp float_cmp_zero(ConstExprValue *op) {
7213 if (op->type->id == TypeTableEntryIdNumLitFloat) {
7213 if (op->type->id == TypeTableEntryIdComptimeFloat) {
72147214 return bigfloat_cmp_zero(&op->data.x_bigfloat);
72157215 } else if (op->type->id == TypeTableEntryIdFloat) {
72167216 switch (op->type->data.floating.bit_count) {
......@@ -7251,7 +7251,7 @@ static Cmp float_cmp_zero(ConstExprValue *op) {
72517251static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
72527252 assert(op1->type == op2->type);
72537253 out_val->type = op1->type;
7254 if (op1->type->id == TypeTableEntryIdNumLitFloat) {
7254 if (op1->type->id == TypeTableEntryIdComptimeFloat) {
72557255 bigfloat_add(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);
72567256 } else if (op1->type->id == TypeTableEntryIdFloat) {
72577257 switch (op1->type->data.floating.bit_count) {
......@@ -7275,7 +7275,7 @@ static void float_add(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal
72757275static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
72767276 assert(op1->type == op2->type);
72777277 out_val->type = op1->type;
7278 if (op1->type->id == TypeTableEntryIdNumLitFloat) {
7278 if (op1->type->id == TypeTableEntryIdComptimeFloat) {
72797279 bigfloat_sub(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);
72807280 } else if (op1->type->id == TypeTableEntryIdFloat) {
72817281 switch (op1->type->data.floating.bit_count) {
......@@ -7299,7 +7299,7 @@ static void float_sub(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal
72997299static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
73007300 assert(op1->type == op2->type);
73017301 out_val->type = op1->type;
7302 if (op1->type->id == TypeTableEntryIdNumLitFloat) {
7302 if (op1->type->id == TypeTableEntryIdComptimeFloat) {
73037303 bigfloat_mul(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);
73047304 } else if (op1->type->id == TypeTableEntryIdFloat) {
73057305 switch (op1->type->data.floating.bit_count) {
......@@ -7323,7 +7323,7 @@ static void float_mul(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal
73237323static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
73247324 assert(op1->type == op2->type);
73257325 out_val->type = op1->type;
7326 if (op1->type->id == TypeTableEntryIdNumLitFloat) {
7326 if (op1->type->id == TypeTableEntryIdComptimeFloat) {
73277327 bigfloat_div(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);
73287328 } else if (op1->type->id == TypeTableEntryIdFloat) {
73297329 switch (op1->type->data.floating.bit_count) {
......@@ -7347,7 +7347,7 @@ static void float_div(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal
73477347static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
73487348 assert(op1->type == op2->type);
73497349 out_val->type = op1->type;
7350 if (op1->type->id == TypeTableEntryIdNumLitFloat) {
7350 if (op1->type->id == TypeTableEntryIdComptimeFloat) {
73517351 bigfloat_div_trunc(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);
73527352 } else if (op1->type->id == TypeTableEntryIdFloat) {
73537353 switch (op1->type->data.floating.bit_count) {
......@@ -7382,7 +7382,7 @@ static void float_div_trunc(ConstExprValue *out_val, ConstExprValue *op1, ConstE
73827382static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
73837383 assert(op1->type == op2->type);
73847384 out_val->type = op1->type;
7385 if (op1->type->id == TypeTableEntryIdNumLitFloat) {
7385 if (op1->type->id == TypeTableEntryIdComptimeFloat) {
73867386 bigfloat_div_floor(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);
73877387 } else if (op1->type->id == TypeTableEntryIdFloat) {
73887388 switch (op1->type->data.floating.bit_count) {
......@@ -7407,7 +7407,7 @@ static void float_div_floor(ConstExprValue *out_val, ConstExprValue *op1, ConstE
74077407static void float_rem(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
74087408 assert(op1->type == op2->type);
74097409 out_val->type = op1->type;
7410 if (op1->type->id == TypeTableEntryIdNumLitFloat) {
7410 if (op1->type->id == TypeTableEntryIdComptimeFloat) {
74117411 bigfloat_rem(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);
74127412 } else if (op1->type->id == TypeTableEntryIdFloat) {
74137413 switch (op1->type->data.floating.bit_count) {
......@@ -7431,7 +7431,7 @@ static void float_rem(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal
74317431static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprValue *op2) {
74327432 assert(op1->type == op2->type);
74337433 out_val->type = op1->type;
7434 if (op1->type->id == TypeTableEntryIdNumLitFloat) {
7434 if (op1->type->id == TypeTableEntryIdComptimeFloat) {
74357435 bigfloat_mod(&out_val->data.x_bigfloat, &op1->data.x_bigfloat, &op2->data.x_bigfloat);
74367436 } else if (op1->type->id == TypeTableEntryIdFloat) {
74377437 switch (op1->type->data.floating.bit_count) {
......@@ -7456,7 +7456,7 @@ static void float_mod(ConstExprValue *out_val, ConstExprValue *op1, ConstExprVal
74567456
74577457static void float_negate(ConstExprValue *out_val, ConstExprValue *op) {
74587458 out_val->type = op->type;
7459 if (op->type->id == TypeTableEntryIdNumLitFloat) {
7459 if (op->type->id == TypeTableEntryIdComptimeFloat) {
74607460 bigfloat_negate(&out_val->data.x_bigfloat, &op->data.x_bigfloat);
74617461 } else if (op->type->id == TypeTableEntryIdFloat) {
74627462 switch (op->type->data.floating.bit_count) {
......@@ -7530,9 +7530,9 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc
75307530 assert(const_val->special != ConstValSpecialRuntime);
75317531
75327532 bool const_val_is_int = (const_val->type->id == TypeTableEntryIdInt ||
7533 const_val->type->id == TypeTableEntryIdNumLitInt);
7533 const_val->type->id == TypeTableEntryIdComptimeInt);
75347534 bool const_val_is_float = (const_val->type->id == TypeTableEntryIdFloat ||
7535 const_val->type->id == TypeTableEntryIdNumLitFloat);
7535 const_val->type->id == TypeTableEntryIdComptimeFloat);
75367536 if (other_type->id == TypeTableEntryIdFloat) {
75377537 return true;
75387538 } else if (other_type->id == TypeTableEntryIdInt && const_val_is_int) {
......@@ -7576,7 +7576,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc
75767576 return true;
75777577 }
75787578 }
7579 if (explicit_cast && (other_type->id == TypeTableEntryIdInt || other_type->id == TypeTableEntryIdNumLitInt) &&
7579 if (explicit_cast && (other_type->id == TypeTableEntryIdInt || other_type->id == TypeTableEntryIdComptimeInt) &&
75807580 const_val_is_float)
75817581 {
75827582 if (float_has_fraction(const_val)) {
......@@ -7589,7 +7589,7 @@ static bool ir_num_lit_fits_in_other_type(IrAnalyze *ira, IrInstruction *instruc
75897589 buf_ptr(&other_type->name)));
75907590 return false;
75917591 } else {
7592 if (other_type->id == TypeTableEntryIdNumLitInt) {
7592 if (other_type->id == TypeTableEntryIdComptimeInt) {
75937593 return true;
75947594 } else {
75957595 BigInt bigint;
......@@ -8078,8 +8078,8 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,
80788078
80798079 // implicit number literal to typed number
80808080 // implicit number literal to &const integer
8081 if (actual_type->id == TypeTableEntryIdNumLitFloat ||
8082 actual_type->id == TypeTableEntryIdNumLitInt)
8081 if (actual_type->id == TypeTableEntryIdComptimeFloat ||
8082 actual_type->id == TypeTableEntryIdComptimeInt)
80838083 {
80848084 if (expected_type->id == TypeTableEntryIdPointer &&
80858085 expected_type->data.pointer.is_const)
......@@ -8099,9 +8099,9 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,
80998099 // implicit typed number to integer or float literal.
81008100 // works when the number is known
81018101 if (value->value.special == ConstValSpecialStatic) {
8102 if (actual_type->id == TypeTableEntryIdInt && expected_type->id == TypeTableEntryIdNumLitInt) {
8102 if (actual_type->id == TypeTableEntryIdInt && expected_type->id == TypeTableEntryIdComptimeInt) {
81038103 return ImplicitCastMatchResultYes;
8104 } else if (actual_type->id == TypeTableEntryIdFloat && expected_type->id == TypeTableEntryIdNumLitFloat) {
8104 } else if (actual_type->id == TypeTableEntryIdFloat && expected_type->id == TypeTableEntryIdComptimeFloat) {
81058105 return ImplicitCastMatchResultYes;
81068106 }
81078107 }
......@@ -8555,8 +8555,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
85558555 continue;
85568556 }
85578557
8558 if (prev_type->id == TypeTableEntryIdNumLitInt ||
8559 prev_type->id == TypeTableEntryIdNumLitFloat)
8558 if (prev_type->id == TypeTableEntryIdComptimeInt ||
8559 prev_type->id == TypeTableEntryIdComptimeFloat)
85608560 {
85618561 if (ir_num_lit_fits_in_other_type(ira, prev_inst, cur_type, false)) {
85628562 prev_inst = cur_inst;
......@@ -8566,8 +8566,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
85668566 }
85678567 }
85688568
8569 if (cur_type->id == TypeTableEntryIdNumLitInt ||
8570 cur_type->id == TypeTableEntryIdNumLitFloat)
8569 if (cur_type->id == TypeTableEntryIdComptimeInt ||
8570 cur_type->id == TypeTableEntryIdComptimeFloat)
85718571 {
85728572 if (ir_num_lit_fits_in_other_type(ira, cur_inst, prev_type, false)) {
85738573 continue;
......@@ -8671,8 +8671,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
86718671 } else if (expected_type != nullptr && expected_type->id == TypeTableEntryIdErrorUnion) {
86728672 return get_error_union_type(ira->codegen, err_set_type, expected_type->data.error_union.payload_type);
86738673 } else {
8674 if (prev_inst->value.type->id == TypeTableEntryIdNumLitInt ||
8675 prev_inst->value.type->id == TypeTableEntryIdNumLitFloat)
8674 if (prev_inst->value.type->id == TypeTableEntryIdComptimeInt ||
8675 prev_inst->value.type->id == TypeTableEntryIdComptimeFloat)
86768676 {
86778677 ir_add_error_node(ira, source_node,
86788678 buf_sprintf("unable to make error union out of number literal"));
......@@ -8686,8 +8686,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
86868686 }
86878687 }
86888688 } else if (any_are_null && prev_inst->value.type->id != TypeTableEntryIdNullLit) {
8689 if (prev_inst->value.type->id == TypeTableEntryIdNumLitInt ||
8690 prev_inst->value.type->id == TypeTableEntryIdNumLitFloat)
8689 if (prev_inst->value.type->id == TypeTableEntryIdComptimeInt ||
8690 prev_inst->value.type->id == TypeTableEntryIdComptimeFloat)
86918691 {
86928692 ir_add_error_node(ira, source_node,
86938693 buf_sprintf("unable to make maybe out of number literal"));
......@@ -8743,7 +8743,7 @@ static void eval_const_expr_implicit_cast(CastOp cast_op,
87438743 break;
87448744 }
87458745 case CastOpNumLitToConcrete:
8746 if (other_val->type->id == TypeTableEntryIdNumLitFloat) {
8746 if (other_val->type->id == TypeTableEntryIdComptimeFloat) {
87478747 assert(new_type->id == TypeTableEntryIdFloat);
87488748 switch (new_type->data.floating.bit_count) {
87498749 case 32:
......@@ -8758,7 +8758,7 @@ static void eval_const_expr_implicit_cast(CastOp cast_op,
87588758 default:
87598759 zig_unreachable();
87608760 }
8761 } else if (other_val->type->id == TypeTableEntryIdNumLitInt) {
8761 } else if (other_val->type->id == TypeTableEntryIdComptimeInt) {
87628762 bigint_init_bigint(&const_val->data.x_bigint, &other_val->data.x_bigint);
87638763 } else {
87648764 zig_unreachable();
......@@ -9601,9 +9601,9 @@ static IrInstruction *ir_analyze_number_to_literal(IrAnalyze *ira, IrInstruction
96019601
96029602 IrInstruction *result = ir_create_const(&ira->new_irb, source_instr->scope,
96039603 source_instr->source_node, wanted_type);
9604 if (wanted_type->id == TypeTableEntryIdNumLitFloat) {
9604 if (wanted_type->id == TypeTableEntryIdComptimeFloat) {
96059605 float_init_float(&result->value, val);
9606 } else if (wanted_type->id == TypeTableEntryIdNumLitInt) {
9606 } else if (wanted_type->id == TypeTableEntryIdComptimeInt) {
96079607 bigint_init_bigint(&result->value.data.x_bigint, &val->data.x_bigint);
96089608 } else {
96099609 zig_unreachable();
......@@ -9978,8 +9978,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
99789978 TypeTableEntry *wanted_child_type = wanted_type->data.maybe.child_type;
99799979 if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node).id == ConstCastResultIdOk) {
99809980 return ir_analyze_maybe_wrap(ira, source_instr, value, wanted_type);
9981 } else if (actual_type->id == TypeTableEntryIdNumLitInt ||
9982 actual_type->id == TypeTableEntryIdNumLitFloat)
9981 } else if (actual_type->id == TypeTableEntryIdComptimeInt ||
9982 actual_type->id == TypeTableEntryIdComptimeFloat)
99839983 {
99849984 if (ir_num_lit_fits_in_other_type(ira, value, wanted_child_type, true)) {
99859985 return ir_analyze_maybe_wrap(ira, source_instr, value, wanted_type);
......@@ -10013,8 +10013,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1001310013 if (wanted_type->id == TypeTableEntryIdErrorUnion) {
1001410014 if (types_match_const_cast_only(ira, wanted_type->data.error_union.payload_type, actual_type, source_node).id == ConstCastResultIdOk) {
1001510015 return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type);
10016 } else if (actual_type->id == TypeTableEntryIdNumLitInt ||
10017 actual_type->id == TypeTableEntryIdNumLitFloat)
10016 } else if (actual_type->id == TypeTableEntryIdComptimeInt ||
10017 actual_type->id == TypeTableEntryIdComptimeFloat)
1001810018 {
1001910019 if (ir_num_lit_fits_in_other_type(ira, value, wanted_type->data.error_union.payload_type, true)) {
1002010020 return ir_analyze_err_wrap_payload(ira, source_instr, value, wanted_type);
......@@ -10062,8 +10062,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1006210062 TypeTableEntry *wanted_child_type = wanted_type->data.error_union.payload_type->data.maybe.child_type;
1006310063 if (types_match_const_cast_only(ira, wanted_child_type, actual_type, source_node).id == ConstCastResultIdOk ||
1006410064 actual_type->id == TypeTableEntryIdNullLit ||
10065 actual_type->id == TypeTableEntryIdNumLitInt ||
10066 actual_type->id == TypeTableEntryIdNumLitFloat)
10065 actual_type->id == TypeTableEntryIdComptimeInt ||
10066 actual_type->id == TypeTableEntryIdComptimeFloat)
1006710067 {
1006810068 IrInstruction *cast1 = ir_analyze_cast(ira, source_instr, wanted_type->data.error_union.payload_type, value);
1006910069 if (type_is_invalid(cast1->value.type))
......@@ -10079,8 +10079,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1007910079
1008010080 // explicit cast from number literal to another type
1008110081 // explicit cast from number literal to &const integer
10082 if (actual_type->id == TypeTableEntryIdNumLitFloat ||
10083 actual_type->id == TypeTableEntryIdNumLitInt)
10082 if (actual_type->id == TypeTableEntryIdComptimeFloat ||
10083 actual_type->id == TypeTableEntryIdComptimeInt)
1008410084 {
1008510085 ensure_complete_type(ira->codegen, wanted_type);
1008610086 if (type_is_invalid(wanted_type))
......@@ -10109,9 +10109,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1010910109 return cast2;
1011010110 } else if (ir_num_lit_fits_in_other_type(ira, value, wanted_type, true)) {
1011110111 CastOp op;
10112 if ((actual_type->id == TypeTableEntryIdNumLitFloat &&
10112 if ((actual_type->id == TypeTableEntryIdComptimeFloat &&
1011310113 wanted_type->id == TypeTableEntryIdFloat) ||
10114 (actual_type->id == TypeTableEntryIdNumLitInt &&
10114 (actual_type->id == TypeTableEntryIdComptimeInt &&
1011510115 wanted_type->id == TypeTableEntryIdInt))
1011610116 {
1011710117 op = CastOpNumLitToConcrete;
......@@ -10131,8 +10131,8 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1013110131 // explicit cast from typed number to integer or float literal.
1013210132 // works when the number is known at compile time
1013310133 if (instr_is_comptime(value) &&
10134 ((actual_type->id == TypeTableEntryIdInt && wanted_type->id == TypeTableEntryIdNumLitInt) ||
10135 (actual_type->id == TypeTableEntryIdFloat && wanted_type->id == TypeTableEntryIdNumLitFloat)))
10134 ((actual_type->id == TypeTableEntryIdInt && wanted_type->id == TypeTableEntryIdComptimeInt) ||
10135 (actual_type->id == TypeTableEntryIdFloat && wanted_type->id == TypeTableEntryIdComptimeFloat)))
1013610136 {
1013710137 return ir_analyze_number_to_literal(ira, source_instr, value, wanted_type);
1013810138 }
......@@ -10759,8 +10759,8 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
1075910759 case TypeTableEntryIdInvalid:
1076010760 zig_unreachable(); // handled above
1076110761
10762 case TypeTableEntryIdNumLitFloat:
10763 case TypeTableEntryIdNumLitInt:
10762 case TypeTableEntryIdComptimeFloat:
10763 case TypeTableEntryIdComptimeInt:
1076410764 case TypeTableEntryIdInt:
1076510765 case TypeTableEntryIdFloat:
1076610766 break;
......@@ -10818,10 +10818,10 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
1081810818 bool one_possible_value = !type_requires_comptime(resolved_type) && !type_has_bits(resolved_type);
1081910819 if (one_possible_value || (value_is_comptime(op1_val) && value_is_comptime(op2_val))) {
1082010820 bool answer;
10821 if (resolved_type->id == TypeTableEntryIdNumLitFloat || resolved_type->id == TypeTableEntryIdFloat) {
10821 if (resolved_type->id == TypeTableEntryIdComptimeFloat || resolved_type->id == TypeTableEntryIdFloat) {
1082210822 Cmp cmp_result = float_cmp(op1_val, op2_val);
1082310823 answer = resolve_cmp_op_id(op_id, cmp_result);
10824 } else if (resolved_type->id == TypeTableEntryIdNumLitInt || resolved_type->id == TypeTableEntryIdInt) {
10824 } else if (resolved_type->id == TypeTableEntryIdComptimeInt || resolved_type->id == TypeTableEntryIdInt) {
1082510825 Cmp cmp_result = bigint_cmp(&op1_val->data.x_bigint, &op2_val->data.x_bigint);
1082610826 answer = resolve_cmp_op_id(op_id, cmp_result);
1082710827 } else {
......@@ -10885,12 +10885,12 @@ static int ir_eval_math_op(TypeTableEntry *type_entry, ConstExprValue *op1_val,
1088510885 bool is_int;
1088610886 bool is_float;
1088710887 Cmp op2_zcmp;
10888 if (type_entry->id == TypeTableEntryIdInt || type_entry->id == TypeTableEntryIdNumLitInt) {
10888 if (type_entry->id == TypeTableEntryIdInt || type_entry->id == TypeTableEntryIdComptimeInt) {
1088910889 is_int = true;
1089010890 is_float = false;
1089110891 op2_zcmp = bigint_cmp_zero(&op2_val->data.x_bigint);
1089210892 } else if (type_entry->id == TypeTableEntryIdFloat ||
10893 type_entry->id == TypeTableEntryIdNumLitFloat)
10893 type_entry->id == TypeTableEntryIdComptimeFloat)
1089410894 {
1089510895 is_int = false;
1089610896 is_float = true;
......@@ -11064,7 +11064,7 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *
1106411064 if (type_is_invalid(op1->value.type))
1106511065 return ira->codegen->builtin_types.entry_invalid;
1106611066
11067 if (op1->value.type->id != TypeTableEntryIdInt && op1->value.type->id != TypeTableEntryIdNumLitInt) {
11067 if (op1->value.type->id != TypeTableEntryIdInt && op1->value.type->id != TypeTableEntryIdComptimeInt) {
1106811068 ir_add_error(ira, &bin_op_instruction->base,
1106911069 buf_sprintf("bit shifting operation expected integer type, found '%s'",
1107011070 buf_ptr(&op1->value.type->name)));
......@@ -11077,7 +11077,7 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *
1107711077
1107811078 IrInstruction *casted_op2;
1107911079 IrBinOp op_id = bin_op_instruction->op_id;
11080 if (op1->value.type->id == TypeTableEntryIdNumLitInt) {
11080 if (op1->value.type->id == TypeTableEntryIdComptimeInt) {
1108111081 casted_op2 = op2;
1108211082
1108311083 if (op_id == IrBinOpBitShiftLeftLossy) {
......@@ -11122,7 +11122,7 @@ static TypeTableEntry *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *
1112211122
1112311123 ir_num_lit_fits_in_other_type(ira, result_instruction, op1->value.type, false);
1112411124 return op1->value.type;
11125 } else if (op1->value.type->id == TypeTableEntryIdNumLitInt) {
11125 } else if (op1->value.type->id == TypeTableEntryIdComptimeInt) {
1112611126 ir_add_error(ira, &bin_op_instruction->base,
1112711127 buf_sprintf("LHS of shift must be an integer type, or RHS must be compile-time known"));
1112811128 return ira->codegen->builtin_types.entry_invalid;
......@@ -11158,15 +11158,15 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1115811158 if (type_is_invalid(resolved_type))
1115911159 return resolved_type;
1116011160
11161 bool is_int = resolved_type->id == TypeTableEntryIdInt || resolved_type->id == TypeTableEntryIdNumLitInt;
11162 bool is_float = resolved_type->id == TypeTableEntryIdFloat || resolved_type->id == TypeTableEntryIdNumLitFloat;
11161 bool is_int = resolved_type->id == TypeTableEntryIdInt || resolved_type->id == TypeTableEntryIdComptimeInt;
11162 bool is_float = resolved_type->id == TypeTableEntryIdFloat || resolved_type->id == TypeTableEntryIdComptimeFloat;
1116311163 bool is_signed_div = (
1116411164 (resolved_type->id == TypeTableEntryIdInt && resolved_type->data.integral.is_signed) ||
1116511165 resolved_type->id == TypeTableEntryIdFloat ||
11166 (resolved_type->id == TypeTableEntryIdNumLitFloat &&
11166 (resolved_type->id == TypeTableEntryIdComptimeFloat &&
1116711167 ((bigfloat_cmp_zero(&op1->value.data.x_bigfloat) != CmpGT) !=
1116811168 (bigfloat_cmp_zero(&op2->value.data.x_bigfloat) != CmpGT))) ||
11169 (resolved_type->id == TypeTableEntryIdNumLitInt &&
11169 (resolved_type->id == TypeTableEntryIdComptimeInt &&
1117011170 ((bigint_cmp_zero(&op1->value.data.x_bigint) != CmpGT) !=
1117111171 (bigint_cmp_zero(&op2->value.data.x_bigint) != CmpGT)))
1117211172 );
......@@ -11267,7 +11267,7 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp
1126711267 return ira->codegen->builtin_types.entry_invalid;
1126811268 }
1126911269
11270 if (resolved_type->id == TypeTableEntryIdNumLitInt) {
11270 if (resolved_type->id == TypeTableEntryIdComptimeInt) {
1127111271 if (op_id == IrBinOpAddWrap) {
1127211272 op_id = IrBinOpAdd;
1127311273 } else if (op_id == IrBinOpSubWrap) {
......@@ -11641,8 +11641,8 @@ static VarClassRequired get_var_class_required(TypeTableEntry *type_entry) {
1164111641 case TypeTableEntryIdFn:
1164211642 case TypeTableEntryIdPromise:
1164311643 return VarClassRequiredAny;
11644 case TypeTableEntryIdNumLitFloat:
11645 case TypeTableEntryIdNumLitInt:
11644 case TypeTableEntryIdComptimeFloat:
11645 case TypeTableEntryIdComptimeInt:
1164611646 case TypeTableEntryIdUndefLit:
1164711647 case TypeTableEntryIdBlock:
1164811648 case TypeTableEntryIdNullLit:
......@@ -11910,8 +11910,8 @@ static TypeTableEntry *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructi
1191011910 case TypeTableEntryIdMetaType:
1191111911 case TypeTableEntryIdVoid:
1191211912 case TypeTableEntryIdUnreachable:
11913 case TypeTableEntryIdNumLitFloat:
11914 case TypeTableEntryIdNumLitInt:
11913 case TypeTableEntryIdComptimeFloat:
11914 case TypeTableEntryIdComptimeInt:
1191511915 case TypeTableEntryIdUndefLit:
1191611916 case TypeTableEntryIdNullLit:
1191711917 case TypeTableEntryIdMaybe:
......@@ -11934,8 +11934,8 @@ static TypeTableEntry *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructi
1193411934 case TypeTableEntryIdFloat:
1193511935 case TypeTableEntryIdPointer:
1193611936 case TypeTableEntryIdArray:
11937 case TypeTableEntryIdNumLitFloat:
11938 case TypeTableEntryIdNumLitInt:
11937 case TypeTableEntryIdComptimeFloat:
11938 case TypeTableEntryIdComptimeInt:
1193911939 case TypeTableEntryIdUndefLit:
1194011940 case TypeTableEntryIdNullLit:
1194111941 case TypeTableEntryIdMaybe:
......@@ -12149,7 +12149,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
1214912149 }
1215012150
1215112151 bool comptime_arg = param_decl_node->data.param_decl.is_inline ||
12152 casted_arg->value.type->id == TypeTableEntryIdNumLitInt || casted_arg->value.type->id == TypeTableEntryIdNumLitFloat;
12152 casted_arg->value.type->id == TypeTableEntryIdComptimeInt || casted_arg->value.type->id == TypeTableEntryIdComptimeFloat;
1215312153
1215412154 ConstExprValue *arg_val;
1215512155
......@@ -12174,8 +12174,8 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
1217412174 var->shadowable = !comptime_arg;
1217512175
1217612176 *next_proto_i += 1;
12177 } else if (casted_arg->value.type->id == TypeTableEntryIdNumLitInt ||
12178 casted_arg->value.type->id == TypeTableEntryIdNumLitFloat)
12177 } else if (casted_arg->value.type->id == TypeTableEntryIdComptimeInt ||
12178 casted_arg->value.type->id == TypeTableEntryIdComptimeFloat)
1217912179 {
1218012180 ir_add_error(ira, casted_arg,
1218112181 buf_sprintf("compiler bug: integer and float literals in var args function must be casted. https://github.com/ziglang/zig/issues/557"));
......@@ -12898,8 +12898,8 @@ static TypeTableEntry *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op
1289812898 case TypeTableEntryIdPointer:
1289912899 case TypeTableEntryIdArray:
1290012900 case TypeTableEntryIdStruct:
12901 case TypeTableEntryIdNumLitFloat:
12902 case TypeTableEntryIdNumLitInt:
12901 case TypeTableEntryIdComptimeFloat:
12902 case TypeTableEntryIdComptimeInt:
1290312903 case TypeTableEntryIdUndefLit:
1290412904 case TypeTableEntryIdNullLit:
1290512905 case TypeTableEntryIdMaybe:
......@@ -12935,10 +12935,10 @@ static TypeTableEntry *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un
1293512935
1293612936 bool is_wrap_op = (un_op_instruction->op_id == IrUnOpNegationWrap);
1293712937
12938 bool is_float = (expr_type->id == TypeTableEntryIdFloat || expr_type->id == TypeTableEntryIdNumLitFloat);
12938 bool is_float = (expr_type->id == TypeTableEntryIdFloat || expr_type->id == TypeTableEntryIdComptimeFloat);
1293912939
1294012940 if ((expr_type->id == TypeTableEntryIdInt && expr_type->data.integral.is_signed) ||
12941 expr_type->id == TypeTableEntryIdNumLitInt || (is_float && !is_wrap_op))
12941 expr_type->id == TypeTableEntryIdComptimeInt || (is_float && !is_wrap_op))
1294212942 {
1294312943 if (instr_is_comptime(value)) {
1294412944 ConstExprValue *target_const_val = ir_resolve_const(ira, value, UndefBad);
......@@ -12954,7 +12954,7 @@ static TypeTableEntry *ir_analyze_negation(IrAnalyze *ira, IrInstructionUnOp *un
1295412954 } else {
1295512955 bigint_negate(&out_val->data.x_bigint, &target_const_val->data.x_bigint);
1295612956 }
12957 if (is_wrap_op || is_float || expr_type->id == TypeTableEntryIdNumLitInt) {
12957 if (is_wrap_op || is_float || expr_type->id == TypeTableEntryIdComptimeInt) {
1295812958 return expr_type;
1295912959 }
1296012960
......@@ -13150,8 +13150,8 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP
1315013150 if (type_is_invalid(resolved_type))
1315113151 return resolved_type;
1315213152
13153 if (resolved_type->id == TypeTableEntryIdNumLitFloat ||
13154 resolved_type->id == TypeTableEntryIdNumLitInt ||
13153 if (resolved_type->id == TypeTableEntryIdComptimeFloat ||
13154 resolved_type->id == TypeTableEntryIdComptimeInt ||
1315513155 resolved_type->id == TypeTableEntryIdNullLit ||
1315613156 resolved_type->id == TypeTableEntryIdUndefLit)
1315713157 {
......@@ -14213,8 +14213,8 @@ static TypeTableEntry *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructi
1421314213 switch (type_entry->id) {
1421414214 case TypeTableEntryIdInvalid:
1421514215 zig_unreachable(); // handled above
14216 case TypeTableEntryIdNumLitFloat:
14217 case TypeTableEntryIdNumLitInt:
14216 case TypeTableEntryIdComptimeFloat:
14217 case TypeTableEntryIdComptimeInt:
1421814218 case TypeTableEntryIdUndefLit:
1421914219 case TypeTableEntryIdNullLit:
1422014220 case TypeTableEntryIdNamespace:
......@@ -14495,8 +14495,8 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,
1449514495 case TypeTableEntryIdPointer:
1449614496 case TypeTableEntryIdArray:
1449714497 case TypeTableEntryIdStruct:
14498 case TypeTableEntryIdNumLitFloat:
14499 case TypeTableEntryIdNumLitInt:
14498 case TypeTableEntryIdComptimeFloat:
14499 case TypeTableEntryIdComptimeInt:
1450014500 case TypeTableEntryIdMaybe:
1450114501 case TypeTableEntryIdErrorUnion:
1450214502 case TypeTableEntryIdErrorSet:
......@@ -14603,8 +14603,8 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira,
1460314603 case TypeTableEntryIdPointer:
1460414604 case TypeTableEntryIdArray:
1460514605 case TypeTableEntryIdStruct:
14606 case TypeTableEntryIdNumLitFloat:
14607 case TypeTableEntryIdNumLitInt:
14606 case TypeTableEntryIdComptimeFloat:
14607 case TypeTableEntryIdComptimeInt:
1460814608 case TypeTableEntryIdMaybe:
1460914609 case TypeTableEntryIdErrorUnion:
1461014610 case TypeTableEntryIdErrorSet:
......@@ -14659,8 +14659,8 @@ static TypeTableEntry *ir_analyze_instruction_size_of(IrAnalyze *ira,
1465914659 case TypeTableEntryIdUndefLit:
1466014660 case TypeTableEntryIdNullLit:
1466114661 case TypeTableEntryIdBlock:
14662 case TypeTableEntryIdNumLitFloat:
14663 case TypeTableEntryIdNumLitInt:
14662 case TypeTableEntryIdComptimeFloat:
14663 case TypeTableEntryIdComptimeInt:
1466414664 case TypeTableEntryIdBoundFn:
1466514665 case TypeTableEntryIdMetaType:
1466614666 case TypeTableEntryIdNamespace:
......@@ -15020,8 +15020,8 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,
1502015020 case TypeTableEntryIdBool:
1502115021 case TypeTableEntryIdInt:
1502215022 case TypeTableEntryIdFloat:
15023 case TypeTableEntryIdNumLitFloat:
15024 case TypeTableEntryIdNumLitInt:
15023 case TypeTableEntryIdComptimeFloat:
15024 case TypeTableEntryIdComptimeInt:
1502515025 case TypeTableEntryIdPointer:
1502615026 case TypeTableEntryIdPromise:
1502715027 case TypeTableEntryIdFn:
......@@ -15618,8 +15618,8 @@ static TypeTableEntry *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_
1561815618 case TypeTableEntryIdPromise:
1561915619 case TypeTableEntryIdArray:
1562015620 case TypeTableEntryIdStruct:
15621 case TypeTableEntryIdNumLitFloat:
15622 case TypeTableEntryIdNumLitInt:
15621 case TypeTableEntryIdComptimeFloat:
15622 case TypeTableEntryIdComptimeInt:
1562315623 case TypeTableEntryIdUndefLit:
1562415624 case TypeTableEntryIdNullLit:
1562515625 case TypeTableEntryIdMaybe:
......@@ -16280,8 +16280,8 @@ static ConstExprValue *ir_make_type_info_value(IrAnalyze *ira, TypeTableEntry *t
1628016280 case TypeTableEntryIdVoid:
1628116281 case TypeTableEntryIdBool:
1628216282 case TypeTableEntryIdUnreachable:
16283 case TypeTableEntryIdNumLitFloat:
16284 case TypeTableEntryIdNumLitInt:
16283 case TypeTableEntryIdComptimeFloat:
16284 case TypeTableEntryIdComptimeInt:
1628516285 case TypeTableEntryIdUndefLit:
1628616286 case TypeTableEntryIdNullLit:
1628716287 case TypeTableEntryIdNamespace:
......@@ -17143,7 +17143,7 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc
1714317143 return ira->codegen->builtin_types.entry_invalid;
1714417144
1714517145 if (dest_type->id != TypeTableEntryIdInt &&
17146 dest_type->id != TypeTableEntryIdNumLitInt)
17146 dest_type->id != TypeTableEntryIdComptimeInt)
1714717147 {
1714817148 ir_add_error(ira, dest_type_value, buf_sprintf("expected integer type, found '%s'", buf_ptr(&dest_type->name)));
1714917149 return ira->codegen->builtin_types.entry_invalid;
......@@ -17155,7 +17155,7 @@ static TypeTableEntry *ir_analyze_instruction_truncate(IrAnalyze *ira, IrInstruc
1715517155 return ira->codegen->builtin_types.entry_invalid;
1715617156
1715717157 if (src_type->id != TypeTableEntryIdInt &&
17158 src_type->id != TypeTableEntryIdNumLitInt)
17158 src_type->id != TypeTableEntryIdComptimeInt)
1715917159 {
1716017160 ir_add_error(ira, target, buf_sprintf("expected integer type, found '%s'", buf_ptr(&src_type->name)));
1716117161 return ira->codegen->builtin_types.entry_invalid;
......@@ -17876,8 +17876,8 @@ static TypeTableEntry *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruc
1787617876 zig_unreachable();
1787717877 case TypeTableEntryIdMetaType:
1787817878 case TypeTableEntryIdUnreachable:
17879 case TypeTableEntryIdNumLitFloat:
17880 case TypeTableEntryIdNumLitInt:
17879 case TypeTableEntryIdComptimeFloat:
17880 case TypeTableEntryIdComptimeInt:
1788117881 case TypeTableEntryIdUndefLit:
1788217882 case TypeTableEntryIdNullLit:
1788317883 case TypeTableEntryIdNamespace:
......@@ -18377,8 +18377,8 @@ static TypeTableEntry *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira
1837718377 if (!end_val)
1837818378 return ira->codegen->builtin_types.entry_invalid;
1837918379
18380 assert(start_val->type->id == TypeTableEntryIdInt || start_val->type->id == TypeTableEntryIdNumLitInt);
18381 assert(end_val->type->id == TypeTableEntryIdInt || end_val->type->id == TypeTableEntryIdNumLitInt);
18380 assert(start_val->type->id == TypeTableEntryIdInt || start_val->type->id == TypeTableEntryIdComptimeInt);
18381 assert(end_val->type->id == TypeTableEntryIdInt || end_val->type->id == TypeTableEntryIdComptimeInt);
1838218382 AstNode *prev_node = rangeset_add_range(&rs, &start_val->data.x_bigint, &end_val->data.x_bigint,
1838318383 start_value->source_node);
1838418384 if (prev_node != nullptr) {
......@@ -18610,8 +18610,8 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue
1861018610 case TypeTableEntryIdNamespace:
1861118611 case TypeTableEntryIdBlock:
1861218612 case TypeTableEntryIdUnreachable:
18613 case TypeTableEntryIdNumLitFloat:
18614 case TypeTableEntryIdNumLitInt:
18613 case TypeTableEntryIdComptimeFloat:
18614 case TypeTableEntryIdComptimeInt:
1861518615 case TypeTableEntryIdUndefLit:
1861618616 case TypeTableEntryIdNullLit:
1861718617 case TypeTableEntryIdPromise:
......@@ -18677,8 +18677,8 @@ static void buf_read_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue
1867718677 case TypeTableEntryIdNamespace:
1867818678 case TypeTableEntryIdBlock:
1867918679 case TypeTableEntryIdUnreachable:
18680 case TypeTableEntryIdNumLitFloat:
18681 case TypeTableEntryIdNumLitInt:
18680 case TypeTableEntryIdComptimeFloat:
18681 case TypeTableEntryIdComptimeInt:
1868218682 case TypeTableEntryIdUndefLit:
1868318683 case TypeTableEntryIdNullLit:
1868418684 case TypeTableEntryIdPromise:
......@@ -18758,8 +18758,8 @@ static TypeTableEntry *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruc
1875818758 case TypeTableEntryIdNamespace:
1875918759 case TypeTableEntryIdBlock:
1876018760 case TypeTableEntryIdUnreachable:
18761 case TypeTableEntryIdNumLitFloat:
18762 case TypeTableEntryIdNumLitInt:
18761 case TypeTableEntryIdComptimeFloat:
18762 case TypeTableEntryIdComptimeInt:
1876318763 case TypeTableEntryIdUndefLit:
1876418764 case TypeTableEntryIdNullLit:
1876518765 ir_add_error(ira, dest_type_value,
......@@ -18784,8 +18784,8 @@ static TypeTableEntry *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstruc
1878418784 case TypeTableEntryIdNamespace:
1878518785 case TypeTableEntryIdBlock:
1878618786 case TypeTableEntryIdUnreachable:
18787 case TypeTableEntryIdNumLitFloat:
18788 case TypeTableEntryIdNumLitInt:
18787 case TypeTableEntryIdComptimeFloat:
18788 case TypeTableEntryIdComptimeInt:
1878918789 case TypeTableEntryIdUndefLit:
1879018790 case TypeTableEntryIdNullLit:
1879118791 ir_add_error(ira, dest_type_value,
......@@ -19560,7 +19560,7 @@ static TypeTableEntry *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstruction
1956019560 if (type_is_invalid(op->value.type))
1956119561 return ira->codegen->builtin_types.entry_invalid;
1956219562
19563 bool ok_type = float_type->id == TypeTableEntryIdNumLitFloat || float_type->id == TypeTableEntryIdFloat;
19563 bool ok_type = float_type->id == TypeTableEntryIdComptimeFloat || float_type->id == TypeTableEntryIdFloat;
1956419564 if (!ok_type) {
1956519565 ir_add_error(ira, instruction->type, buf_sprintf("@sqrt does not support type '%s'", buf_ptr(&float_type->name)));
1956619566 return ira->codegen->builtin_types.entry_invalid;
......@@ -19577,7 +19577,7 @@ static TypeTableEntry *ir_analyze_instruction_sqrt(IrAnalyze *ira, IrInstruction
1957719577
1957819578 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1957919579
19580 if (float_type->id == TypeTableEntryIdNumLitFloat) {
19580 if (float_type->id == TypeTableEntryIdComptimeFloat) {
1958119581 bigfloat_sqrt(&out_val->data.x_bigfloat, &val->data.x_bigfloat);
1958219582 } else if (float_type->id == TypeTableEntryIdFloat) {
1958319583 switch (float_type->data.floating.bit_count) {
std/math/ln.zig+2-2
......@@ -14,7 +14,7 @@ const TypeId = builtin.TypeId;
1414pub fn ln(x: var) @typeOf(x) {
1515 const T = @typeOf(x);
1616 switch (@typeId(T)) {
17 TypeId.FloatLiteral => {
17 TypeId.ComptimeFloat => {
1818 return @typeOf(1.0)(ln_64(x));
1919 },
2020 TypeId.Float => {
......@@ -24,7 +24,7 @@ pub fn ln(x: var) @typeOf(x) {
2424 else => @compileError("ln not implemented for " ++ @typeName(T)),
2525 };
2626 },
27 TypeId.IntLiteral => {
27 TypeId.ComptimeInt => {
2828 return @typeOf(1)(math.floor(ln_64(f64(x))));
2929 },
3030 TypeId.Int => {
std/math/log.zig+3-3
......@@ -9,15 +9,15 @@ pub fn log(comptime T: type, base: T, x: T) T {
99 return math.log2(x);
1010 } else if (base == 10) {
1111 return math.log10(x);
12 } else if ((@typeId(T) == TypeId.Float or @typeId(T) == TypeId.FloatLiteral) and base == math.e) {
12 } else if ((@typeId(T) == TypeId.Float or @typeId(T) == TypeId.ComptimeFloat) and base == math.e) {
1313 return math.ln(x);
1414 }
1515
1616 switch (@typeId(T)) {
17 TypeId.FloatLiteral => {
17 TypeId.ComptimeFloat => {
1818 return @typeOf(1.0)(math.ln(f64(x)) / math.ln(f64(base)));
1919 },
20 TypeId.IntLiteral => {
20 TypeId.ComptimeInt => {
2121 return @typeOf(1)(math.floor(math.ln(f64(x)) / math.ln(f64(base))));
2222 },
2323 builtin.TypeId.Int => {
std/math/log10.zig+2-2
......@@ -14,7 +14,7 @@ const TypeId = builtin.TypeId;
1414pub fn log10(x: var) @typeOf(x) {
1515 const T = @typeOf(x);
1616 switch (@typeId(T)) {
17 TypeId.FloatLiteral => {
17 TypeId.ComptimeFloat => {
1818 return @typeOf(1.0)(log10_64(x));
1919 },
2020 TypeId.Float => {
......@@ -24,7 +24,7 @@ pub fn log10(x: var) @typeOf(x) {
2424 else => @compileError("log10 not implemented for " ++ @typeName(T)),
2525 };
2626 },
27 TypeId.IntLiteral => {
27 TypeId.ComptimeInt => {
2828 return @typeOf(1)(math.floor(log10_64(f64(x))));
2929 },
3030 TypeId.Int => {
std/math/log2.zig+2-2
......@@ -14,7 +14,7 @@ const TypeId = builtin.TypeId;
1414pub fn log2(x: var) @typeOf(x) {
1515 const T = @typeOf(x);
1616 switch (@typeId(T)) {
17 TypeId.FloatLiteral => {
17 TypeId.ComptimeFloat => {
1818 return @typeOf(1.0)(log2_64(x));
1919 },
2020 TypeId.Float => {
......@@ -24,7 +24,7 @@ pub fn log2(x: var) @typeOf(x) {
2424 else => @compileError("log2 not implemented for " ++ @typeName(T)),
2525 };
2626 },
27 TypeId.IntLiteral => comptime {
27 TypeId.ComptimeInt => comptime {
2828 var result = 0;
2929 var x_shifted = x;
3030 while (b: {
std/math/sqrt.zig+2-2
......@@ -14,9 +14,9 @@ const TypeId = builtin.TypeId;
1414pub fn sqrt(x: var) (if (@typeId(@typeOf(x)) == TypeId.Int) @IntType(false, @typeOf(x).bit_count / 2) else @typeOf(x)) {
1515 const T = @typeOf(x);
1616 switch (@typeId(T)) {
17 TypeId.FloatLiteral => return T(@sqrt(f64, x)), // TODO upgrade to f128
17 TypeId.ComptimeFloat => return T(@sqrt(f64, x)), // TODO upgrade to f128
1818 TypeId.Float => return @sqrt(T, x),
19 TypeId.IntLiteral => comptime {
19 TypeId.ComptimeInt => comptime {
2020 if (x > @maxValue(u128)) {
2121 @compileError("sqrt not implemented for comptime_int greater than 128 bits");
2222 }
test/cases/math.zig+18-6
......@@ -329,14 +329,14 @@ fn testShrExact(x: u8) void {
329329 assert(shifted == 0b00101101);
330330}
331331
332test "big number addition" {
332test "comptime_int addition" {
333333 comptime {
334334 assert(35361831660712422535336160538497375248 + 101752735581729509668353361206450473702 == 137114567242441932203689521744947848950);
335335 assert(594491908217841670578297176641415611445982232488944558774612 + 390603545391089362063884922208143568023166603618446395589768 == 985095453608931032642182098849559179469148836107390954364380);
336336 }
337337}
338338
339test "big number multiplication" {
339test "comptime_int multiplication" {
340340 comptime {
341341 assert(
342342 45960427431263824329884196484953148229 * 128339149605334697009938835852565949723 == 5898522172026096622534201617172456926982464453350084962781392314016180490567,
......@@ -347,13 +347,13 @@ test "big number multiplication" {
347347 }
348348}
349349
350test "big number shifting" {
350test "comptime_int shifting" {
351351 comptime {
352352 assert((u128(1) << 127) == 0x80000000000000000000000000000000);
353353 }
354354}
355355
356test "big number multi-limb shift and mask" {
356test "comptime_int multi-limb shift and mask" {
357357 comptime {
358358 var a = 0xefffffffa0000001eeeeeeefaaaaaaab;
359359
......@@ -370,7 +370,7 @@ test "big number multi-limb shift and mask" {
370370 }
371371}
372372
373test "big number multi-limb partial shift right" {
373test "comptime_int multi-limb partial shift right" {
374374 comptime {
375375 var a = 0x1ffffffffeeeeeeee;
376376 a >>= 16;
......@@ -391,7 +391,7 @@ fn test_xor() void {
391391 assert(0xFF ^ 0xFF == 0x00);
392392}
393393
394test "big number xor" {
394test "comptime_int xor" {
395395 comptime {
396396 assert(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ^ 0x00000000000000000000000000000000 == 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
397397 assert(0xFFFFFFFFFFFFFFFF0000000000000000 ^ 0x0000000000000000FFFFFFFFFFFFFFFF == 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
......@@ -449,3 +449,15 @@ test "@sqrt" {
449449fn testSqrt(comptime T: type, x: T) void {
450450 assert(@sqrt(T, x * x) == x);
451451}
452
453test "comptime_int param and return" {
454 const a = comptimeAdd(35361831660712422535336160538497375248, 101752735581729509668353361206450473702);
455 assert(a == 137114567242441932203689521744947848950);
456
457 const b = comptimeAdd(594491908217841670578297176641415611445982232488944558774612, 390603545391089362063884922208143568023166603618446395589768);
458 assert(b == 985095453608931032642182098849559179469148836107390954364380);
459}
460
461fn comptimeAdd(comptime a: comptime_int, comptime b: comptime_int) comptime_int {
462 return a + b;
463}
test/cases/misc.zig+2-2
......@@ -501,8 +501,8 @@ test "@typeId" {
501501 assert(@typeId(*f32) == Tid.Pointer);
502502 assert(@typeId([2]u8) == Tid.Array);
503503 assert(@typeId(AStruct) == Tid.Struct);
504 assert(@typeId(@typeOf(1)) == Tid.IntLiteral);
505 assert(@typeId(@typeOf(1.0)) == Tid.FloatLiteral);
504 assert(@typeId(@typeOf(1)) == Tid.ComptimeInt);
505 assert(@typeId(@typeOf(1.0)) == Tid.ComptimeFloat);
506506 assert(@typeId(@typeOf(undefined)) == Tid.UndefinedLiteral);
507507 assert(@typeId(@typeOf(null)) == Tid.NullLiteral);
508508 assert(@typeId(?i32) == Tid.Nullable);
test/compile_errors.zig+6-6
......@@ -1539,7 +1539,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
15391539 \\fn foo() *const i32 { return y; }
15401540 \\export fn entry() usize { return @sizeOf(@typeOf(foo)); }
15411541 ,
1542 ".tmp_source.zig:3:30: error: expected type '*const i32', found '*const (integer literal)'",
1542 ".tmp_source.zig:3:30: error: expected type '*const i32', found '*const comptime_int'",
15431543 );
15441544
15451545 cases.add(
......@@ -1555,7 +1555,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
15551555 \\const x = 2 == 2.0;
15561556 \\export fn entry() usize { return @sizeOf(@typeOf(x)); }
15571557 ,
1558 ".tmp_source.zig:1:11: error: integer value 2 cannot be implicitly casted to type '(float literal)'",
1558 ".tmp_source.zig:1:11: error: integer value 2 cannot be implicitly casted to type 'comptime_float'",
15591559 );
15601560
15611561 cases.add(
......@@ -2189,7 +2189,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
21892189 \\
21902190 \\export fn entry() usize { return @sizeOf(@typeOf(block_aligned_stuff)); }
21912191 ,
2192 ".tmp_source.zig:3:60: error: unable to perform binary not operation on type '(integer literal)'",
2192 ".tmp_source.zig:3:60: error: unable to perform binary not operation on type 'comptime_int'",
21932193 );
21942194
21952195 cases.addCase(x: {
......@@ -3269,10 +3269,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
32693269 \\ fn bar(self: *const Foo) void {}
32703270 \\};
32713271 ,
3272 ".tmp_source.zig:4:4: error: variable of type '*(integer literal)' must be const or comptime",
3272 ".tmp_source.zig:4:4: error: variable of type '*comptime_int' must be const or comptime",
32733273 ".tmp_source.zig:7:4: error: variable of type '(undefined)' must be const or comptime",
3274 ".tmp_source.zig:8:4: error: variable of type '(integer literal)' must be const or comptime",
3275 ".tmp_source.zig:9:4: error: variable of type '(float literal)' must be const or comptime",
3274 ".tmp_source.zig:8:4: error: variable of type 'comptime_int' must be const or comptime",
3275 ".tmp_source.zig:9:4: error: variable of type 'comptime_float' must be const or comptime",
32763276 ".tmp_source.zig:10:4: error: variable of type '(block)' must be const or comptime",
32773277 ".tmp_source.zig:11:4: error: variable of type '(null)' must be const or comptime",
32783278 ".tmp_source.zig:12:4: error: variable of type 'Opaque' must be const or comptime",