Skip to content

[wgsl-in] Incorrect handling of negative integers with hex values #4492

@Wumpf

Description

@Wumpf

The following isn't accepted right now (note that this is how the spec defines the minimum integer https://www.w3.org/TR/WGSL/#integer-types)

const i32min = i32(-0x80000000);

Instead this is accepted and probably shouldn't:

const i32min = -0x80000000i

In fact, Tint will fail this with:

Tint WGSL reader failure: :24:17 error: value cannot be represented as 'i32'
const i32min = -0x80000000i; // Tint can't handle this being represented as `-0x80000000i`

I thought originally that this is the actual error, but I think the reasoning over at the chrome bug I opened is correct and above should be rejected, see https://bugs.chromium.org/p/chromium/issues/detail?id=1439274

For anyone else running into this, note that const i32min = -2147483648; is accepted by both compilers.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions