diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-04-06 02:39:55 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-04-06 02:39:55 -0700 |
| commit | 62f54aa39cb3dca3055033a57bc4626e94061aec (patch) | |
| tree | bb358aa300f71f548f3ac8847ff8130d44bed9fb /src | |
| parent | 9213aa789b4b44711f2747e5ab053a2b1f57a15b (diff) | |
| download | zig-62f54aa39cb3dca3055033a57bc4626e94061aec.tar.gz zig-62f54aa39cb3dca3055033a57bc4626e94061aec.zip | |
Sema: in-memory coercion of differently named int types
which have the same number of bits and the same signedness.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Sema.zig | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 90fe93ed88..ae6d95ef96 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -18458,6 +18458,17 @@ fn coerceInMemoryAllowed( if (dest_ty.eql(src_ty, target)) return .ok; + // Differently-named integers with the same number of bits. + if (dest_ty.zigTypeTag() == .Int and src_ty.zigTypeTag() == .Int) { + const dest_info = dest_ty.intInfo(target); + const src_info = src_ty.intInfo(target); + if (dest_info.signedness == src_info.signedness and + dest_info.bits == src_info.bits) + { + return .ok; + } + } + // Pointers / Pointer-like Optionals var dest_buf: Type.Payload.ElemType = undefined; var src_buf: Type.Payload.ElemType = undefined; |
