mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 21:08:36 +00:00
Fix peer type resolution
This commit is contained in:
parent
7b88215a49
commit
de093879cc
@ -2661,11 +2661,15 @@ pub fn resolvePeerTypes(self: *Module, scope: *Scope, instructions: []*Inst) !Ty
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((prev_inst.ty.zigTypeTag() == .ComptimeInt and next_inst.ty.isInt()) or (next_inst.ty.zigTypeTag() == .ComptimeInt and prev_inst.ty.isInt())) {
|
||||
if (prev_inst.ty.zigTypeTag() == .ComptimeInt and next_inst.ty.isInt()) {
|
||||
prev_inst = next_inst;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (prev_inst.ty.isInt() and next_inst.ty.zigTypeTag() == .ComptimeInt) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO error notes pointing out each type
|
||||
return self.fail(scope, next_inst.src, "incompatible types: '{}' and '{}'", .{ prev_inst.ty, next_inst.ty });
|
||||
}
|
||||
|
||||
@ -195,4 +195,52 @@ pub fn addCases(ctx: *TestContext) !void {
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
ctx.c("exit with u8 arithmetic inverted", linux_x64,
|
||||
\\export fn _start() noreturn {
|
||||
\\ exitMath(1);
|
||||
\\}
|
||||
\\
|
||||
\\fn exitMath(a: u8) noreturn {
|
||||
\\ exit(a + 0 - a);
|
||||
\\}
|
||||
\\
|
||||
\\fn exit(code: u8) noreturn {
|
||||
\\ asm volatile ("syscall"
|
||||
\\ :
|
||||
\\ : [number] "{rax}" (231),
|
||||
\\ [arg1] "{rdi}" (code)
|
||||
\\ );
|
||||
\\ unreachable;
|
||||
\\}
|
||||
\\
|
||||
,
|
||||
\\#include <stddef.h>
|
||||
\\#include <stdint.h>
|
||||
\\
|
||||
\\zig_noreturn void exitMath(uint8_t arg0);
|
||||
\\zig_noreturn void exit(uint8_t arg0);
|
||||
\\
|
||||
\\const char *const exit__anon_0 = "{rax}";
|
||||
\\const char *const exit__anon_1 = "{rdi}";
|
||||
\\const char *const exit__anon_2 = "syscall";
|
||||
\\
|
||||
\\zig_noreturn void _start(void) {
|
||||
\\ exitMath(1);
|
||||
\\}
|
||||
\\
|
||||
\\zig_noreturn void exitMath(uint8_t arg0) {
|
||||
\\ const uint8_t __temp_0 = arg0 + 0;
|
||||
\\ const uint8_t __temp_1 = __temp_0 - arg0;
|
||||
\\ exit(__temp_1);
|
||||
\\}
|
||||
\\
|
||||
\\zig_noreturn void exit(uint8_t arg0) {
|
||||
\\ const size_t __temp_0 = (size_t)arg0;
|
||||
\\ register size_t rax_constant __asm__("rax") = 231;
|
||||
\\ register size_t rdi_constant __asm__("rdi") = __temp_0;
|
||||
\\ __asm volatile ("syscall" :: ""(rax_constant), ""(rdi_constant));
|
||||
\\ zig_unreachable();
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user