aboutsummaryrefslogtreecommitdiff
path: root/src/value.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-02-08 22:09:41 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-02-08 22:09:41 -0700
commit59418d1bf6f82866a1c8f3b35fd815bb7add5129 (patch)
treeab4876e312c85234a158099b075b45fee1da0879 /src/value.zig
parent470c8ca48c32d34da06e4741b8f81b6eb0d72fd7 (diff)
downloadzig-59418d1bf6f82866a1c8f3b35fd815bb7add5129.tar.gz
zig-59418d1bf6f82866a1c8f3b35fd815bb7add5129.zip
Sema: fix Value.intFitsInType for comptime int
Diffstat (limited to 'src/value.zig')
-rw-r--r--src/value.zig34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/value.zig b/src/value.zig
index acc3fa3d74..9e1f4c0ed6 100644
--- a/src/value.zig
+++ b/src/value.zig
@@ -1331,12 +1331,16 @@ pub const Value = extern union {
.one,
.bool_true,
- => {
- const info = ty.intInfo(target);
- return switch (info.signedness) {
- .signed => info.bits >= 2,
- .unsigned => info.bits >= 1,
- };
+ => switch (ty.zigTypeTag()) {
+ .Int => {
+ const info = ty.intInfo(target);
+ return switch (info.signedness) {
+ .signed => info.bits >= 2,
+ .unsigned => info.bits >= 1,
+ };
+ },
+ .ComptimeInt => return true,
+ else => unreachable,
},
.int_u64 => switch (ty.zigTypeTag()) {
@@ -1390,13 +1394,17 @@ pub const Value = extern union {
.decl_ref,
.function,
.variable,
- => {
- const info = ty.intInfo(target);
- const ptr_bits = target.cpu.arch.ptrBitWidth();
- return switch (info.signedness) {
- .signed => info.bits > ptr_bits,
- .unsigned => info.bits >= ptr_bits,
- };
+ => switch (ty.zigTypeTag()) {
+ .Int => {
+ const info = ty.intInfo(target);
+ const ptr_bits = target.cpu.arch.ptrBitWidth();
+ return switch (info.signedness) {
+ .signed => info.bits > ptr_bits,
+ .unsigned => info.bits >= ptr_bits,
+ };
+ },
+ .ComptimeInt => return true,
+ else => unreachable,
},
else => unreachable,