Skip to content

wrong error when using a unit struct as length of a repeat expression #27008

Closed
@oli-obk

Description

@oli-obk
struct A { i: i32};
let a = [0; A{i: 42}];

yields the expected

error: expected positive integer for repeat count, found struct [E0306]

while

struct B;
let b = [0; B];

thinks that B is a variable

error: expected constant integer for repeat count, found variable [E0307]

PlayPen

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions