Another fix to #2226

This commit is contained in:
Christoffer Lerno
2025-06-23 00:36:15 +02:00
parent aff3a3f746
commit 0d147a48b2
2 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
module test;
typedef Byte = inline ushort;
macro Byte Byte.add(self, int other) @operator_s(+) => (Byte)((ushort)self + (ushort)other);
fn int main(String[] args)
{
Byte b = 2;
Byte c = 1;
Byte d = c + b;
return 0;
}
/* #expect: test.ll
define i32 @test.main([2 x i64] %0) #0 {
entry:
%args = alloca %"char[][]", align 8
%b = alloca i16, align 2
%c = alloca i16, align 2
%d = alloca i16, align 2
%self = alloca i16, align 2
store [2 x i64] %0, ptr %args, align 8
store i16 2, ptr %b, align 2
store i16 1, ptr %c, align 2
%1 = load i16, ptr %c, align 2
store i16 %1, ptr %self, align 2
%2 = load i16, ptr %b, align 2
%zext = zext i16 %2 to i32
%3 = load i16, ptr %self, align 2
%zext1 = zext i16 %3 to i32
%trunc = trunc i32 %zext to i16
%zext2 = zext i16 %trunc to i32
%add = add i32 %zext1, %zext2
%trunc3 = trunc i32 %add to i16
store i16 %trunc3, ptr %d, align 2
ret i32 0
}