Summary
An i64 const initialized with an integer literal is rejected: the literal infers as i32 and is not context-typed to the declared const type. The only accepted form is an explicit as i64 cast.
Repro
const X: i64 = 1; // error[E2001]: const `X`: expected Scalar[i64] but found Scalar[i32]
const Y: i64 = 1i64; // also error — integer suffix not supported
const Z: i64 = 1 as i64; // OK (the only accepted form)
Impact
Every i64 const with a literal value must be written <n> as i64, which is noisy at scale (e.g. a file with ~30 such consts needs the cast on every one).
Options
- (a) Context-type a const initializer literal to the declared const type (preferred — least surprise), or
- (b) support integer-literal suffixes (
1i64, 255u8).
Add tests for both forms.
Summary
An
i64const initialized with an integer literal is rejected: the literal infers asi32and is not context-typed to the declared const type. The only accepted form is an explicitas i64cast.Repro
Impact
Every
i64const with a literal value must be written<n> as i64, which is noisy at scale (e.g. a file with ~30 such consts needs the cast on every one).Options
1i64,255u8).Add tests for both forms.