Skip to content

An array type's length cannot be a const: [i32; N] is 'expected array size after ;' #2121

Closed

Description

@ehartford

Spec §4.3a: "Length N must be a compile-time constant (integer literal or const)."

const N: i32 = 3
fn main:
    var xs: [i32; N] = [0; N]
    print(xs.len())

Installed compiler from main (dad25d8): error: expected array size after ';' at N in the type. [N]i32 fails the same way; only a literal is accepted. Found while checking D90 point 3 (a std.libc constant in every constant-expression position: an array sized by PATH_MAX would hit this).

Activity

  1. ehartford commented on Oct 5, 2026

    @ehartford
    ContributorAuthor

    Fixed on main 0ade380 (stack #2175, battery green; the stack top also builds and passes its new tests on linux-x86_64 and windows-x86_64).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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