Skip to content

Wraparound +% not for literals? #964

Closed
@PavelVozenilek

Description

@PavelVozenilek

I try this in online tool:

const std = @import("std");
const warn = std.debug.warn;

pub fn main() void {

  const o : u8 = 200 +% 200;
  warn("{}\n", o);    
}

and it gives me error:

/home/runner/.code.tio:6:22: error: integer value 400 cannot be implicitly casted to type 'u8'

I expected wraparounds to work at compile time too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions