authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-06-05 10:16:51-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2018-06-05 10:16:51-04:00
log677eaf29b10df9b1dc461b37e7be78734b11ef19
tree3046287688eeb219464fcb2c2ba1fd34185b1a0c
parente53b683bd3958a7b1c517e2391edce42b9d4e48b
parenta8146ade2a57bea12ea2d16bd273f03578e5d559
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #1057 from ziglang/comptime-int

Rename integer literal type and float literal type

13 files changed, 355 insertions(+), 341 deletions(-)

doc/langref.html.in+16-16
......@@ -4893,10 +4893,10 @@ pub const TypeId = enum {
48934893 Pointer,
48944894 Array,
48954895 Struct,
4896 FloatLiteral,
4897 IntLiteral,
4898 UndefinedLiteral,
4899 NullLiteral,
4896 ComptimeFloat,
4897 ComptimeInt,
4898 Undefined,
4899 Null,
49004900 Nullable,
49014901 ErrorUnion,
49024902 Error,
......@@ -4927,10 +4927,10 @@ pub const TypeInfo = union(TypeId) {
49274927 Pointer: Pointer,
49284928 Array: Array,
49294929 Struct: Struct,
4930 FloatLiteral: void,
4931 IntLiteral: void,
4932 UndefinedLiteral: void,
4933 NullLiteral: void,
4930 ComptimeFloat: void,
4931 ComptimeInt: void,
4932 Undefined: void,
4933 Null: void,
49344934 Nullable: Nullable,
49354935 ErrorUnion: ErrorUnion,
49364936 ErrorSet: ErrorSet,
......@@ -5685,10 +5685,10 @@ pub const TypeId = enum {
56855685 Pointer,
56865686 Array,
56875687 Struct,
5688 FloatLiteral,
5689 IntLiteral,
5690 UndefinedLiteral,
5691 NullLiteral,
5688 ComptimeFloat,
5689 ComptimeInt,
5690 Undefined,
5691 Null,
56925692 Nullable,
56935693 ErrorUnion,
56945694 ErrorSet,
......@@ -5713,10 +5713,10 @@ pub const TypeInfo = union(TypeId) {
57135713 Pointer: Pointer,
57145714 Array: Array,
57155715 Struct: Struct,
5716 FloatLiteral: void,
5717 IntLiteral: void,
5718 UndefinedLiteral: void,
5719 NullLiteral: void,
5716 ComptimeFloat: void,
5717 ComptimeInt: void,
5718 Undefined: void,
5719 Null: void,
57205720 Nullable: Nullable,
57215721 ErrorUnion: ErrorUnion,
57225722 ErrorSet: ErrorSet,
src/all_types.hpp+4-4
......@@ -1159,10 +1159,10 @@ enum TypeTableEntryId {
11591159 TypeTableEntryIdPointer,
11601160 TypeTableEntryIdArray,
11611161 TypeTableEntryIdStruct,
1162 TypeTableEntryIdNumLitFloat,
1163 TypeTableEntryIdNumLitInt,
1164 TypeTableEntryIdUndefLit,
1165 TypeTableEntryIdNullLit,
1162 TypeTableEntryIdComptimeFloat,
1163 TypeTableEntryIdComptimeInt,
1164 TypeTableEntryIdUndefined,
1165 TypeTableEntryIdNull,
11661166 TypeTableEntryIdMaybe,
11671167 TypeTableEntryIdErrorUnion,
11681168 TypeTableEntryIdErrorSet,
src/analyze.cpp+92-92
......@@ -232,10 +232,10 @@ bool type_is_complete(TypeTableEntry *type_entry) {
232232 case TypeTableEntryIdFloat:
233233 case TypeTableEntryIdPointer:
234234 case TypeTableEntryIdArray:
235 case TypeTableEntryIdNumLitFloat:
236 case TypeTableEntryIdNumLitInt:
237 case TypeTableEntryIdUndefLit:
238 case TypeTableEntryIdNullLit:
235 case TypeTableEntryIdComptimeFloat:
236 case TypeTableEntryIdComptimeInt:
237 case TypeTableEntryIdUndefined:
238 case TypeTableEntryIdNull:
239239 case TypeTableEntryIdMaybe:
240240 case TypeTableEntryIdErrorUnion:
241241 case TypeTableEntryIdErrorSet:
......@@ -268,10 +268,10 @@ bool type_has_zero_bits_known(TypeTableEntry *type_entry) {
268268 case TypeTableEntryIdFloat:
269269 case TypeTableEntryIdPointer:
270270 case TypeTableEntryIdArray:
271 case TypeTableEntryIdNumLitFloat:
272 case TypeTableEntryIdNumLitInt:
273 case TypeTableEntryIdUndefLit:
274 case TypeTableEntryIdNullLit:
271 case TypeTableEntryIdComptimeFloat:
272 case TypeTableEntryIdComptimeInt:
273 case TypeTableEntryIdUndefined:
274 case TypeTableEntryIdNull:
275275 case TypeTableEntryIdMaybe:
276276 case TypeTableEntryIdErrorUnion:
277277 case TypeTableEntryIdErrorSet:
......@@ -1333,10 +1333,10 @@ 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:
1338 case TypeTableEntryIdUndefLit:
1339 case TypeTableEntryIdNullLit:
1336 case TypeTableEntryIdComptimeFloat:
1337 case TypeTableEntryIdComptimeInt:
1338 case TypeTableEntryIdUndefined:
1339 case TypeTableEntryIdNull:
13401340 case TypeTableEntryIdErrorUnion:
13411341 case TypeTableEntryIdErrorSet:
13421342 case TypeTableEntryIdNamespace:
......@@ -1374,10 +1374,10 @@ 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:
1379 case TypeTableEntryIdUndefLit:
1380 case TypeTableEntryIdNullLit:
1377 case TypeTableEntryIdComptimeFloat:
1378 case TypeTableEntryIdComptimeInt:
1379 case TypeTableEntryIdUndefined:
1380 case TypeTableEntryIdNull:
13811381 case TypeTableEntryIdErrorUnion:
13821382 case TypeTableEntryIdErrorSet:
13831383 case TypeTableEntryIdNamespace:
......@@ -1511,15 +1511,15 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
15111511 case TypeTableEntryIdInvalid:
15121512 return g->builtin_types.entry_invalid;
15131513 case TypeTableEntryIdUnreachable:
1514 case TypeTableEntryIdUndefLit:
1515 case TypeTableEntryIdNullLit:
1514 case TypeTableEntryIdUndefined:
1515 case TypeTableEntryIdNull:
15161516 case TypeTableEntryIdArgTuple:
15171517 case TypeTableEntryIdOpaque:
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:
......@@ -1599,16 +1599,16 @@ static TypeTableEntry *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *c
15991599 case TypeTableEntryIdInvalid:
16001600 zig_unreachable();
16011601
1602 case TypeTableEntryIdUndefLit:
1603 case TypeTableEntryIdNullLit:
1602 case TypeTableEntryIdUndefined:
1603 case TypeTableEntryIdNull:
16041604 case TypeTableEntryIdArgTuple:
16051605 case TypeTableEntryIdOpaque:
16061606 add_node_error(g, fn_proto->return_type,
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,16 +3337,16 @@ 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:
3342 case TypeTableEntryIdUndefLit:
3343 case TypeTableEntryIdNullLit:
3340 case TypeTableEntryIdUndefined:
3341 case TypeTableEntryIdNull:
33443342 case TypeTableEntryIdBlock:
33453343 case TypeTableEntryIdArgTuple:
33463344 case TypeTableEntryIdOpaque:
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,12 +3480,12 @@ 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;
3488 } else if (implicit_type->id == TypeTableEntryIdNullLit) {
3488 } else if (implicit_type->id == TypeTableEntryIdNull) {
34893489 add_node_error(g, source_node, buf_sprintf("unable to infer variable type"));
34903490 implicit_type = g->builtin_types.entry_invalid;
34913491 } else if (implicit_type->id == TypeTableEntryIdMetaType && !is_const) {
......@@ -3730,10 +3730,10 @@ static bool is_container(TypeTableEntry *type_entry) {
37303730 case TypeTableEntryIdInt:
37313731 case TypeTableEntryIdFloat:
37323732 case TypeTableEntryIdArray:
3733 case TypeTableEntryIdNumLitFloat:
3734 case TypeTableEntryIdNumLitInt:
3735 case TypeTableEntryIdUndefLit:
3736 case TypeTableEntryIdNullLit:
3733 case TypeTableEntryIdComptimeFloat:
3734 case TypeTableEntryIdComptimeInt:
3735 case TypeTableEntryIdUndefined:
3736 case TypeTableEntryIdNull:
37373737 case TypeTableEntryIdMaybe:
37383738 case TypeTableEntryIdErrorUnion:
37393739 case TypeTableEntryIdErrorSet:
......@@ -3779,10 +3779,10 @@ void resolve_container_type(CodeGen *g, TypeTableEntry *type_entry) {
37793779 case TypeTableEntryIdInt:
37803780 case TypeTableEntryIdFloat:
37813781 case TypeTableEntryIdArray:
3782 case TypeTableEntryIdNumLitFloat:
3783 case TypeTableEntryIdNumLitInt:
3784 case TypeTableEntryIdUndefLit:
3785 case TypeTableEntryIdNullLit:
3782 case TypeTableEntryIdComptimeFloat:
3783 case TypeTableEntryIdComptimeInt:
3784 case TypeTableEntryIdUndefined:
3785 case TypeTableEntryIdNull:
37863786 case TypeTableEntryIdMaybe:
37873787 case TypeTableEntryIdErrorUnion:
37883788 case TypeTableEntryIdErrorSet:
......@@ -4283,10 +4283,10 @@ bool handle_is_ptr(TypeTableEntry *type_entry) {
42834283 switch (type_entry->id) {
42844284 case TypeTableEntryIdInvalid:
42854285 case TypeTableEntryIdMetaType:
4286 case TypeTableEntryIdNumLitFloat:
4287 case TypeTableEntryIdNumLitInt:
4288 case TypeTableEntryIdUndefLit:
4289 case TypeTableEntryIdNullLit:
4286 case TypeTableEntryIdComptimeFloat:
4287 case TypeTableEntryIdComptimeInt:
4288 case TypeTableEntryIdUndefined:
4289 case TypeTableEntryIdNull:
42904290 case TypeTableEntryIdNamespace:
42914291 case TypeTableEntryIdBlock:
42924292 case TypeTableEntryIdBoundFn:
......@@ -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];
......@@ -4672,9 +4672,9 @@ static uint32_t hash_const_val(ConstExprValue *const_val) {
46724672 case TypeTableEntryIdPromise:
46734673 // TODO better hashing algorithm
46744674 return 223048345;
4675 case TypeTableEntryIdUndefLit:
4675 case TypeTableEntryIdUndefined:
46764676 return 162837799;
4677 case TypeTableEntryIdNullLit:
4677 case TypeTableEntryIdNull:
46784678 return 844854567;
46794679 case TypeTableEntryIdArray:
46804680 // TODO better hashing algorithm
......@@ -4754,10 +4754,10 @@ static bool can_mutate_comptime_var_state(ConstExprValue *value) {
47544754 case TypeTableEntryIdUnreachable:
47554755 case TypeTableEntryIdInt:
47564756 case TypeTableEntryIdFloat:
4757 case TypeTableEntryIdNumLitFloat:
4758 case TypeTableEntryIdNumLitInt:
4759 case TypeTableEntryIdUndefLit:
4760 case TypeTableEntryIdNullLit:
4757 case TypeTableEntryIdComptimeFloat:
4758 case TypeTableEntryIdComptimeInt:
4759 case TypeTableEntryIdUndefined:
4760 case TypeTableEntryIdNull:
47614761 case TypeTableEntryIdNamespace:
47624762 case TypeTableEntryIdBoundFn:
47634763 case TypeTableEntryIdFn:
......@@ -4819,10 +4819,10 @@ static bool return_type_is_cacheable(TypeTableEntry *return_type) {
48194819 case TypeTableEntryIdUnreachable:
48204820 case TypeTableEntryIdInt:
48214821 case TypeTableEntryIdFloat:
4822 case TypeTableEntryIdNumLitFloat:
4823 case TypeTableEntryIdNumLitInt:
4824 case TypeTableEntryIdUndefLit:
4825 case TypeTableEntryIdNullLit:
4822 case TypeTableEntryIdComptimeFloat:
4823 case TypeTableEntryIdComptimeInt:
4824 case TypeTableEntryIdUndefined:
4825 case TypeTableEntryIdNull:
48264826 case TypeTableEntryIdNamespace:
48274827 case TypeTableEntryIdBoundFn:
48284828 case TypeTableEntryIdFn:
......@@ -4930,10 +4930,10 @@ bool type_requires_comptime(TypeTableEntry *type_entry) {
49304930 case TypeTableEntryIdInvalid:
49314931 case TypeTableEntryIdOpaque:
49324932 zig_unreachable();
4933 case TypeTableEntryIdNumLitFloat:
4934 case TypeTableEntryIdNumLitInt:
4935 case TypeTableEntryIdUndefLit:
4936 case TypeTableEntryIdNullLit:
4933 case TypeTableEntryIdComptimeFloat:
4934 case TypeTableEntryIdComptimeInt:
4935 case TypeTableEntryIdUndefined:
4936 case TypeTableEntryIdNull:
49374937 case TypeTableEntryIdMetaType:
49384938 case TypeTableEntryIdNamespace:
49394939 case TypeTableEntryIdBlock:
......@@ -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:
......@@ -5410,9 +5410,9 @@ bool const_values_equal(ConstExprValue *a, ConstExprValue *b) {
54105410 return false;
54115411 }
54125412 return true;
5413 case TypeTableEntryIdUndefLit:
5413 case TypeTableEntryIdUndefined:
54145414 zig_panic("TODO");
5415 case TypeTableEntryIdNullLit:
5415 case TypeTableEntryIdNull:
54165416 zig_panic("TODO");
54175417 case TypeTableEntryIdMaybe:
54185418 if (a->data.x_maybe == nullptr || b->data.x_maybe == nullptr) {
......@@ -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;
......@@ -5646,12 +5646,12 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
56465646 buf_appendf(buf, "}");
56475647 return;
56485648 }
5649 case TypeTableEntryIdNullLit:
5649 case TypeTableEntryIdNull:
56505650 {
56515651 buf_appendf(buf, "null");
56525652 return;
56535653 }
5654 case TypeTableEntryIdUndefLit:
5654 case TypeTableEntryIdUndefined:
56555655 {
56565656 buf_appendf(buf, "undefined");
56575657 return;
......@@ -5761,10 +5761,10 @@ uint32_t type_id_hash(TypeId x) {
57615761 case TypeTableEntryIdUnreachable:
57625762 case TypeTableEntryIdFloat:
57635763 case TypeTableEntryIdStruct:
5764 case TypeTableEntryIdNumLitFloat:
5765 case TypeTableEntryIdNumLitInt:
5766 case TypeTableEntryIdUndefLit:
5767 case TypeTableEntryIdNullLit:
5764 case TypeTableEntryIdComptimeFloat:
5765 case TypeTableEntryIdComptimeInt:
5766 case TypeTableEntryIdUndefined:
5767 case TypeTableEntryIdNull:
57685768 case TypeTableEntryIdMaybe:
57695769 case TypeTableEntryIdErrorSet:
57705770 case TypeTableEntryIdEnum:
......@@ -5807,10 +5807,10 @@ bool type_id_eql(TypeId a, TypeId b) {
58075807 case TypeTableEntryIdUnreachable:
58085808 case TypeTableEntryIdFloat:
58095809 case TypeTableEntryIdStruct:
5810 case TypeTableEntryIdNumLitFloat:
5811 case TypeTableEntryIdNumLitInt:
5812 case TypeTableEntryIdUndefLit:
5813 case TypeTableEntryIdNullLit:
5810 case TypeTableEntryIdComptimeFloat:
5811 case TypeTableEntryIdComptimeInt:
5812 case TypeTableEntryIdUndefined:
5813 case TypeTableEntryIdNull:
58145814 case TypeTableEntryIdMaybe:
58155815 case TypeTableEntryIdPromise:
58165816 case TypeTableEntryIdErrorSet:
......@@ -5929,10 +5929,10 @@ static const TypeTableEntryId all_type_ids[] = {
59295929 TypeTableEntryIdPointer,
59305930 TypeTableEntryIdArray,
59315931 TypeTableEntryIdStruct,
5932 TypeTableEntryIdNumLitFloat,
5933 TypeTableEntryIdNumLitInt,
5934 TypeTableEntryIdUndefLit,
5935 TypeTableEntryIdNullLit,
5932 TypeTableEntryIdComptimeFloat,
5933 TypeTableEntryIdComptimeInt,
5934 TypeTableEntryIdUndefined,
5935 TypeTableEntryIdNull,
59365936 TypeTableEntryIdMaybe,
59375937 TypeTableEntryIdErrorUnion,
59385938 TypeTableEntryIdErrorSet,
......@@ -5980,13 +5980,13 @@ 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;
5987 case TypeTableEntryIdUndefLit:
5987 case TypeTableEntryIdUndefined:
59885988 return 11;
5989 case TypeTableEntryIdNullLit:
5989 case TypeTableEntryIdNull:
59905990 return 12;
59915991 case TypeTableEntryIdMaybe:
59925992 return 13;
......@@ -6038,14 +6038,14 @@ 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";
6045 case TypeTableEntryIdUndefLit:
6046 return "UndefinedLiteral";
6047 case TypeTableEntryIdNullLit:
6048 return "NullLiteral";
6041 case TypeTableEntryIdComptimeFloat:
6042 return "ComptimeFloat";
6043 case TypeTableEntryIdComptimeInt:
6044 return "ComptimeInt";
6045 case TypeTableEntryIdUndefined:
6046 return "Undefined";
6047 case TypeTableEntryIdNull:
6048 return "Null";
60496049 case TypeTableEntryIdMaybe:
60506050 return "Nullable";
60516051 case TypeTableEntryIdErrorUnion:
src/codegen.cpp+34-32
......@@ -4916,10 +4916,10 @@ 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:
4921 case TypeTableEntryIdUndefLit:
4922 case TypeTableEntryIdNullLit:
4919 case TypeTableEntryIdComptimeFloat:
4920 case TypeTableEntryIdComptimeInt:
4921 case TypeTableEntryIdUndefined:
4922 case TypeTableEntryIdNull:
49234923 case TypeTableEntryIdErrorUnion:
49244924 case TypeTableEntryIdErrorSet:
49254925 case TypeTableEntryIdNamespace:
......@@ -5362,10 +5362,10 @@ 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:
5367 case TypeTableEntryIdUndefLit:
5368 case TypeTableEntryIdNullLit:
5365 case TypeTableEntryIdComptimeFloat:
5366 case TypeTableEntryIdComptimeInt:
5367 case TypeTableEntryIdUndefined:
5368 case TypeTableEntryIdNull:
53695369 case TypeTableEntryIdNamespace:
53705370 case TypeTableEntryIdBlock:
53715371 case TypeTableEntryIdBoundFn:
......@@ -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,25 +6012,27 @@ 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 {
6027 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdUndefLit);
6029 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdUndefined);
60286030 buf_init_from_str(&entry->name, "(undefined)");
60296031 entry->zero_bits = true;
60306032 g->builtin_types.entry_undef = entry;
60316033 }
60326034 {
6033 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdNullLit);
6035 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdNull);
60346036 buf_init_from_str(&entry->name, "(null)");
60356037 entry->zero_bits = true;
60366038 g->builtin_types.entry_null = entry;
......@@ -6495,10 +6497,10 @@ 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 " UndefinedLiteral: void,\n"
6501 " NullLiteral: void,\n"
6500 " ComptimeFloat: void,\n"
6501 " ComptimeInt: void,\n"
6502 " Undefined: void,\n"
6503 " Null: void,\n"
65026504 " Nullable: Nullable,\n"
65036505 " ErrorUnion: ErrorUnion,\n"
65046506 " ErrorSet: ErrorSet,\n"
......@@ -7070,10 +7072,10 @@ 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 TypeTableEntryIdUndefLit:
7076 case TypeTableEntryIdNullLit:
7075 case TypeTableEntryIdComptimeFloat:
7076 case TypeTableEntryIdComptimeInt:
7077 case TypeTableEntryIdUndefined:
7078 case TypeTableEntryIdNull:
70777079 case TypeTableEntryIdNamespace:
70787080 case TypeTableEntryIdBlock:
70797081 case TypeTableEntryIdBoundFn:
......@@ -7255,10 +7257,10 @@ 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 TypeTableEntryIdUndefLit:
7261 case TypeTableEntryIdNullLit:
7260 case TypeTableEntryIdComptimeFloat:
7261 case TypeTableEntryIdComptimeInt:
7262 case TypeTableEntryIdUndefined:
7263 case TypeTableEntryIdNull:
72627264 case TypeTableEntryIdArgTuple:
72637265 case TypeTableEntryIdPromise:
72647266 zig_unreachable();
......@@ -7407,11 +7409,11 @@ 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:
7413 case TypeTableEntryIdUndefLit:
7414 case TypeTableEntryIdNullLit:
7415 case TypeTableEntryIdUndefined:
7416 case TypeTableEntryIdNull:
74157417 case TypeTableEntryIdErrorUnion:
74167418 case TypeTableEntryIdErrorSet:
74177419 case TypeTableEntryIdNamespace:
src/ir.cpp+170-170
......@@ -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;
......@@ -7960,7 +7960,7 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,
79607960
79617961 // implicit conversion from null literal to maybe type
79627962 if (expected_type->id == TypeTableEntryIdMaybe &&
7963 actual_type->id == TypeTableEntryIdNullLit)
7963 actual_type->id == TypeTableEntryIdNull)
79647964 {
79657965 return ImplicitCastMatchResultYes;
79667966 }
......@@ -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 }
......@@ -8142,7 +8142,7 @@ static ImplicitCastMatchResult ir_types_match_with_implicit_cast(IrAnalyze *ira,
81428142 }
81438143
81448144 // implicit undefined literal to anything
8145 if (actual_type->id == TypeTableEntryIdUndefLit) {
8145 if (actual_type->id == TypeTableEntryIdUndefined) {
81468146 return ImplicitCastMatchResultYes;
81478147 }
81488148
......@@ -8190,7 +8190,7 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
81908190 }
81918191 }
81928192
8193 bool any_are_null = (prev_inst->value.type->id == TypeTableEntryIdNullLit);
8193 bool any_are_null = (prev_inst->value.type->id == TypeTableEntryIdNull);
81948194 bool convert_to_const_slice = false;
81958195 for (size_t i = 1; i < instruction_count; i += 1) {
81968196 IrInstruction *cur_inst = instructions[i];
......@@ -8469,12 +8469,12 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
84698469 }
84708470 }
84718471
8472 if (prev_type->id == TypeTableEntryIdNullLit) {
8472 if (prev_type->id == TypeTableEntryIdNull) {
84738473 prev_inst = cur_inst;
84748474 continue;
84758475 }
84768476
8477 if (cur_type->id == TypeTableEntryIdNullLit) {
8477 if (cur_type->id == TypeTableEntryIdNull) {
84788478 any_are_null = true;
84798479 continue;
84808480 }
......@@ -8546,17 +8546,17 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
85468546 continue;
85478547 }
85488548
8549 if (cur_type->id == TypeTableEntryIdUndefLit) {
8549 if (cur_type->id == TypeTableEntryIdUndefined) {
85508550 continue;
85518551 }
85528552
8553 if (prev_type->id == TypeTableEntryIdUndefLit) {
8553 if (prev_type->id == TypeTableEntryIdUndefined) {
85548554 prev_inst = cur_inst;
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,13 +8671,13 @@ 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"));
86798679 return ira->codegen->builtin_types.entry_invalid;
8680 } else if (prev_inst->value.type->id == TypeTableEntryIdNullLit) {
8680 } else if (prev_inst->value.type->id == TypeTableEntryIdNull) {
86818681 ir_add_error_node(ira, source_node,
86828682 buf_sprintf("unable to make error union out of null literal"));
86838683 return ira->codegen->builtin_types.entry_invalid;
......@@ -8685,9 +8685,9 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
86858685 return get_error_union_type(ira->codegen, err_set_type, prev_inst->value.type);
86868686 }
86878687 }
8688 } 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)
8688 } else if (any_are_null && prev_inst->value.type->id != TypeTableEntryIdNull) {
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);
......@@ -10004,7 +10004,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1000410004
1000510005 // explicit cast from null literal to maybe type
1000610006 if (wanted_type->id == TypeTableEntryIdMaybe &&
10007 actual_type->id == TypeTableEntryIdNullLit)
10007 actual_type->id == TypeTableEntryIdNull)
1000810008 {
1000910009 return ir_analyze_null_to_maybe(ira, source_instr, value, wanted_type);
1001010010 }
......@@ -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);
......@@ -10061,9 +10061,9 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1006110061 {
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 ||
10064 actual_type->id == TypeTableEntryIdNullLit ||
10065 actual_type->id == TypeTableEntryIdNumLitInt ||
10066 actual_type->id == TypeTableEntryIdNumLitFloat)
10064 actual_type->id == TypeTableEntryIdNull ||
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 }
......@@ -10230,7 +10230,7 @@ static IrInstruction *ir_analyze_cast(IrAnalyze *ira, IrInstruction *source_inst
1023010230
1023110231
1023210232 // explicit cast from undefined to anything
10233 if (actual_type->id == TypeTableEntryIdUndefLit) {
10233 if (actual_type->id == TypeTableEntryIdUndefined) {
1023410234 return ir_analyze_undefined_to_anything(ira, source_instr, value, wanted_type);
1023510235 }
1023610236
......@@ -10627,19 +10627,19 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
1062710627 IrBinOp op_id = bin_op_instruction->op_id;
1062810628 bool is_equality_cmp = (op_id == IrBinOpCmpEq || op_id == IrBinOpCmpNotEq);
1062910629 if (is_equality_cmp &&
10630 ((op1->value.type->id == TypeTableEntryIdNullLit && op2->value.type->id == TypeTableEntryIdMaybe) ||
10631 (op2->value.type->id == TypeTableEntryIdNullLit && op1->value.type->id == TypeTableEntryIdMaybe) ||
10632 (op1->value.type->id == TypeTableEntryIdNullLit && op2->value.type->id == TypeTableEntryIdNullLit)))
10630 ((op1->value.type->id == TypeTableEntryIdNull && op2->value.type->id == TypeTableEntryIdMaybe) ||
10631 (op2->value.type->id == TypeTableEntryIdNull && op1->value.type->id == TypeTableEntryIdMaybe) ||
10632 (op1->value.type->id == TypeTableEntryIdNull && op2->value.type->id == TypeTableEntryIdNull)))
1063310633 {
10634 if (op1->value.type->id == TypeTableEntryIdNullLit && op2->value.type->id == TypeTableEntryIdNullLit) {
10634 if (op1->value.type->id == TypeTableEntryIdNull && op2->value.type->id == TypeTableEntryIdNull) {
1063510635 ConstExprValue *out_val = ir_build_const_from(ira, &bin_op_instruction->base);
1063610636 out_val->data.x_bool = (op_id == IrBinOpCmpEq);
1063710637 return ira->codegen->builtin_types.entry_bool;
1063810638 }
1063910639 IrInstruction *maybe_op;
10640 if (op1->value.type->id == TypeTableEntryIdNullLit) {
10640 if (op1->value.type->id == TypeTableEntryIdNull) {
1064110641 maybe_op = op2;
10642 } else if (op2->value.type->id == TypeTableEntryIdNullLit) {
10642 } else if (op2->value.type->id == TypeTableEntryIdNull) {
1064310643 maybe_op = op1;
1064410644 } else {
1064510645 zig_unreachable();
......@@ -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;
......@@ -10795,8 +10795,8 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
1079510795 case TypeTableEntryIdUnreachable:
1079610796 case TypeTableEntryIdArray:
1079710797 case TypeTableEntryIdStruct:
10798 case TypeTableEntryIdUndefLit:
10799 case TypeTableEntryIdNullLit:
10798 case TypeTableEntryIdUndefined:
10799 case TypeTableEntryIdNull:
1080010800 case TypeTableEntryIdMaybe:
1080110801 case TypeTableEntryIdErrorUnion:
1080210802 case TypeTableEntryIdUnion:
......@@ -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,11 +11641,11 @@ static VarClassRequired get_var_class_required(TypeTableEntry *type_entry) {
1164111641 case TypeTableEntryIdFn:
1164211642 case TypeTableEntryIdPromise:
1164311643 return VarClassRequiredAny;
11644 case TypeTableEntryIdNumLitFloat:
11645 case TypeTableEntryIdNumLitInt:
11646 case TypeTableEntryIdUndefLit:
11644 case TypeTableEntryIdComptimeFloat:
11645 case TypeTableEntryIdComptimeInt:
11646 case TypeTableEntryIdUndefined:
1164711647 case TypeTableEntryIdBlock:
11648 case TypeTableEntryIdNullLit:
11648 case TypeTableEntryIdNull:
1164911649 case TypeTableEntryIdOpaque:
1165011650 case TypeTableEntryIdMetaType:
1165111651 case TypeTableEntryIdNamespace:
......@@ -11910,10 +11910,10 @@ static TypeTableEntry *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructi
1191011910 case TypeTableEntryIdMetaType:
1191111911 case TypeTableEntryIdVoid:
1191211912 case TypeTableEntryIdUnreachable:
11913 case TypeTableEntryIdNumLitFloat:
11914 case TypeTableEntryIdNumLitInt:
11915 case TypeTableEntryIdUndefLit:
11916 case TypeTableEntryIdNullLit:
11913 case TypeTableEntryIdComptimeFloat:
11914 case TypeTableEntryIdComptimeInt:
11915 case TypeTableEntryIdUndefined:
11916 case TypeTableEntryIdNull:
1191711917 case TypeTableEntryIdMaybe:
1191811918 case TypeTableEntryIdErrorUnion:
1191911919 case TypeTableEntryIdErrorSet:
......@@ -11934,10 +11934,10 @@ static TypeTableEntry *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructi
1193411934 case TypeTableEntryIdFloat:
1193511935 case TypeTableEntryIdPointer:
1193611936 case TypeTableEntryIdArray:
11937 case TypeTableEntryIdNumLitFloat:
11938 case TypeTableEntryIdNumLitInt:
11939 case TypeTableEntryIdUndefLit:
11940 case TypeTableEntryIdNullLit:
11937 case TypeTableEntryIdComptimeFloat:
11938 case TypeTableEntryIdComptimeInt:
11939 case TypeTableEntryIdUndefined:
11940 case TypeTableEntryIdNull:
1194111941 case TypeTableEntryIdMaybe:
1194211942 case TypeTableEntryIdErrorUnion:
1194311943 case TypeTableEntryIdErrorSet:
......@@ -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,10 +12898,10 @@ 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:
12903 case TypeTableEntryIdUndefLit:
12904 case TypeTableEntryIdNullLit:
12901 case TypeTableEntryIdComptimeFloat:
12902 case TypeTableEntryIdComptimeInt:
12903 case TypeTableEntryIdUndefined:
12904 case TypeTableEntryIdNull:
1290512905 case TypeTableEntryIdMaybe:
1290612906 case TypeTableEntryIdErrorUnion:
1290712907 case TypeTableEntryIdErrorSet:
......@@ -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,10 +13150,10 @@ 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 ||
13155 resolved_type->id == TypeTableEntryIdNullLit ||
13156 resolved_type->id == TypeTableEntryIdUndefLit)
13153 if (resolved_type->id == TypeTableEntryIdComptimeFloat ||
13154 resolved_type->id == TypeTableEntryIdComptimeInt ||
13155 resolved_type->id == TypeTableEntryIdNull ||
13156 resolved_type->id == TypeTableEntryIdUndefined)
1315713157 {
1315813158 ir_add_error_node(ira, phi_instruction->base.source_node,
1315913159 buf_sprintf("unable to infer expression type"));
......@@ -14213,10 +14213,10 @@ 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:
14218 case TypeTableEntryIdUndefLit:
14219 case TypeTableEntryIdNullLit:
14216 case TypeTableEntryIdComptimeFloat:
14217 case TypeTableEntryIdComptimeInt:
14218 case TypeTableEntryIdUndefined:
14219 case TypeTableEntryIdNull:
1422014220 case TypeTableEntryIdNamespace:
1422114221 case TypeTableEntryIdBlock:
1422214222 case TypeTableEntryIdBoundFn:
......@@ -14479,8 +14479,8 @@ static TypeTableEntry *ir_analyze_instruction_slice_type(IrAnalyze *ira,
1447914479 case TypeTableEntryIdInvalid: // handled above
1448014480 zig_unreachable();
1448114481 case TypeTableEntryIdUnreachable:
14482 case TypeTableEntryIdUndefLit:
14483 case TypeTableEntryIdNullLit:
14482 case TypeTableEntryIdUndefined:
14483 case TypeTableEntryIdNull:
1448414484 case TypeTableEntryIdBlock:
1448514485 case TypeTableEntryIdArgTuple:
1448614486 case TypeTableEntryIdOpaque:
......@@ -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:
......@@ -14587,8 +14587,8 @@ static TypeTableEntry *ir_analyze_instruction_array_type(IrAnalyze *ira,
1458714587 case TypeTableEntryIdInvalid: // handled above
1458814588 zig_unreachable();
1458914589 case TypeTableEntryIdUnreachable:
14590 case TypeTableEntryIdUndefLit:
14591 case TypeTableEntryIdNullLit:
14590 case TypeTableEntryIdUndefined:
14591 case TypeTableEntryIdNull:
1459214592 case TypeTableEntryIdBlock:
1459314593 case TypeTableEntryIdArgTuple:
1459414594 case TypeTableEntryIdOpaque:
......@@ -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:
......@@ -14656,11 +14656,11 @@ static TypeTableEntry *ir_analyze_instruction_size_of(IrAnalyze *ira,
1465614656 case TypeTableEntryIdInvalid: // handled above
1465714657 zig_unreachable();
1465814658 case TypeTableEntryIdUnreachable:
14659 case TypeTableEntryIdUndefLit:
14660 case TypeTableEntryIdNullLit:
14659 case TypeTableEntryIdUndefined:
14660 case TypeTableEntryIdNull:
1466114661 case TypeTableEntryIdBlock:
14662 case TypeTableEntryIdNumLitFloat:
14663 case TypeTableEntryIdNumLitInt:
14662 case TypeTableEntryIdComptimeFloat:
14663 case TypeTableEntryIdComptimeInt:
1466414664 case TypeTableEntryIdBoundFn:
1466514665 case TypeTableEntryIdMetaType:
1466614666 case TypeTableEntryIdNamespace:
......@@ -14713,7 +14713,7 @@ static TypeTableEntry *ir_analyze_instruction_test_non_null(IrAnalyze *ira, IrIn
1471314713
1471414714 ir_build_test_nonnull_from(&ira->new_irb, &instruction->base, value);
1471514715 return ira->codegen->builtin_types.entry_bool;
14716 } else if (type_entry->id == TypeTableEntryIdNullLit) {
14716 } else if (type_entry->id == TypeTableEntryIdNull) {
1471714717 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
1471814718 out_val->data.x_bool = false;
1471914719 return ira->codegen->builtin_types.entry_bool;
......@@ -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:
......@@ -15099,8 +15099,8 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira,
1509915099 case TypeTableEntryIdUnreachable:
1510015100 case TypeTableEntryIdArray:
1510115101 case TypeTableEntryIdStruct:
15102 case TypeTableEntryIdUndefLit:
15103 case TypeTableEntryIdNullLit:
15102 case TypeTableEntryIdUndefined:
15103 case TypeTableEntryIdNull:
1510415104 case TypeTableEntryIdMaybe:
1510515105 case TypeTableEntryIdBlock:
1510615106 case TypeTableEntryIdBoundFn:
......@@ -15618,10 +15618,10 @@ 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:
15623 case TypeTableEntryIdUndefLit:
15624 case TypeTableEntryIdNullLit:
15621 case TypeTableEntryIdComptimeFloat:
15622 case TypeTableEntryIdComptimeInt:
15623 case TypeTableEntryIdUndefined:
15624 case TypeTableEntryIdNull:
1562515625 case TypeTableEntryIdMaybe:
1562615626 case TypeTableEntryIdErrorUnion:
1562715627 case TypeTableEntryIdErrorSet:
......@@ -16280,10 +16280,10 @@ 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:
16285 case TypeTableEntryIdUndefLit:
16286 case TypeTableEntryIdNullLit:
16283 case TypeTableEntryIdComptimeFloat:
16284 case TypeTableEntryIdComptimeInt:
16285 case TypeTableEntryIdUndefined:
16286 case TypeTableEntryIdNull:
1628716287 case TypeTableEntryIdNamespace:
1628816288 case TypeTableEntryIdBlock:
1628916289 case TypeTableEntryIdArgTuple:
......@@ -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,10 +17876,10 @@ 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:
17881 case TypeTableEntryIdUndefLit:
17882 case TypeTableEntryIdNullLit:
17879 case TypeTableEntryIdComptimeFloat:
17880 case TypeTableEntryIdComptimeInt:
17881 case TypeTableEntryIdUndefined:
17882 case TypeTableEntryIdNull:
1788317883 case TypeTableEntryIdNamespace:
1788417884 case TypeTableEntryIdBlock:
1788517885 case TypeTableEntryIdBoundFn:
......@@ -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,10 +18610,10 @@ 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:
18615 case TypeTableEntryIdUndefLit:
18616 case TypeTableEntryIdNullLit:
18613 case TypeTableEntryIdComptimeFloat:
18614 case TypeTableEntryIdComptimeInt:
18615 case TypeTableEntryIdUndefined:
18616 case TypeTableEntryIdNull:
1861718617 case TypeTableEntryIdPromise:
1861818618 zig_unreachable();
1861918619 case TypeTableEntryIdVoid:
......@@ -18677,10 +18677,10 @@ 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:
18682 case TypeTableEntryIdUndefLit:
18683 case TypeTableEntryIdNullLit:
18680 case TypeTableEntryIdComptimeFloat:
18681 case TypeTableEntryIdComptimeInt:
18682 case TypeTableEntryIdUndefined:
18683 case TypeTableEntryIdNull:
1868418684 case TypeTableEntryIdPromise:
1868518685 zig_unreachable();
1868618686 case TypeTableEntryIdVoid:
......@@ -18758,10 +18758,10 @@ 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:
18763 case TypeTableEntryIdUndefLit:
18764 case TypeTableEntryIdNullLit:
18761 case TypeTableEntryIdComptimeFloat:
18762 case TypeTableEntryIdComptimeInt:
18763 case TypeTableEntryIdUndefined:
18764 case TypeTableEntryIdNull:
1876518765 ir_add_error(ira, dest_type_value,
1876618766 buf_sprintf("unable to @bitCast from type '%s'", buf_ptr(&src_type->name)));
1876718767 return ira->codegen->builtin_types.entry_invalid;
......@@ -18784,10 +18784,10 @@ 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:
18789 case TypeTableEntryIdUndefLit:
18790 case TypeTableEntryIdNullLit:
18787 case TypeTableEntryIdComptimeFloat:
18788 case TypeTableEntryIdComptimeInt:
18789 case TypeTableEntryIdUndefined:
18790 case TypeTableEntryIdNull:
1879118791 ir_add_error(ira, dest_type_value,
1879218792 buf_sprintf("unable to @bitCast to type '%s'", buf_ptr(&dest_type->name)));
1879318793 return ira->codegen->builtin_types.entry_invalid;
......@@ -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+4-4
......@@ -501,10 +501,10 @@ 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);
506 assert(@typeId(@typeOf(undefined)) == Tid.UndefinedLiteral);
507 assert(@typeId(@typeOf(null)) == Tid.NullLiteral);
504 assert(@typeId(@typeOf(1)) == Tid.ComptimeInt);
505 assert(@typeId(@typeOf(1.0)) == Tid.ComptimeFloat);
506 assert(@typeId(@typeOf(undefined)) == Tid.Undefined);
507 assert(@typeId(@typeOf(null)) == Tid.Null);
508508 assert(@typeId(?i32) == Tid.Nullable);
509509 assert(@typeId(error!i32) == Tid.ErrorUnion);
510510 assert(@typeId(error) == Tid.ErrorSet);
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",