diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-01-30 15:23:40 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-01-30 15:23:40 -0700 |
| commit | 0c30799d4039c30f95eee29e2c2f8f604e8b9880 (patch) | |
| tree | e9d2a2698abd269d1ecb1fa59051e0950f0954c0 /src/Sema.zig | |
| parent | 91ad96b88a88016043cb0d069aa9db47747170b6 (diff) | |
| download | zig-0c30799d4039c30f95eee29e2c2f8f604e8b9880.tar.gz zig-0c30799d4039c30f95eee29e2c2f8f604e8b9880.zip | |
Sema: fix comptime shl for fixed-width integers
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index b3be9cadc8..7180a0959c 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -7474,11 +7474,17 @@ fn zirShl( } const val = switch (air_tag) { .shl_exact => return sema.fail(block, lhs_src, "TODO implement Sema for comptime shl_exact", .{}), + .shl_sat => if (lhs_ty.zigTypeTag() == .ComptimeInt) try lhs_val.shl(rhs_val, sema.arena) else try lhs_val.shlSat(rhs_val, lhs_ty, sema.arena, sema.mod.getTarget()), - .shl => try lhs_val.shl(rhs_val, sema.arena), + + .shl => if (lhs_ty.zigTypeTag() == .ComptimeInt) + try lhs_val.shl(rhs_val, sema.arena) + else + try lhs_val.shlTrunc(rhs_val, lhs_ty, sema.arena, sema.mod.getTarget()), + else => unreachable, }; |
