Skip to content

Type-checker: i64 const literal requires explicit as i64 cast (no context-typing / no integer suffix) #202

@star-ga

Description

@star-ga

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions