#error: expected type 'type', found 'comptime_int'

1 messages · Page 1 of 1 (latest)

paper spindle
#

I have this code:

// self.pc: u16
// self.address: u16
// read(self: *Cpu6502, addr: u16) u8
fn IZX(self: *Cpu6502) u1 {
        const t: u16 = self.read(self.pc);
        self.pc += 1;

        const lo: 16 = self.read((t + @as(u16, self.x)) & 0x00FF);
        const hi: 16 = self.read((t + @as(u16, self.x) + 1) & 0x00FF);

        self.address = (hi << 8) | lo;
        return 0;
    }

And I got this error:

error: expected type 'type', found 'comptime_int'
        const lo: 16 = self.read((t + @as(u16, self.x)) & 0x00FF);
                       ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Why would it expectd a type and how does my code evaluate to comptime_int?
I don't know if my c brain is playing tricks on me but this code should work right?

I would be very grateful if someone could help me. I would also happily provide more information. I just don't know what else might be relevant

carmine trail
#

Typo and your hint (please correct me if that's not the correct term) is : 16 instead of : u16

paper spindle
#

lmao how could I have missed that.