Skip to content

Why does a static array accept incomplete initialisation? Please make that a warning. #21817

@TurkeyMan

Description

@TurkeyMan
immutable int[5] x = [1, 2, 3, 4, 5]; // <-- this compiles

immutable int[5] x = [1, 2, 3, 4, 5, 6]; // <-- this does not...

immutable int[5] x = [1, 2, 3, 4]; // <-- this compiles (!!!) excusemewtf?!

I'm sure this is un-changeable, but can we please get a warning for this?
I reeeeeallly want this to be something that doesn't silently slip through the cracks!

It wouldn't be such a problem if we could write int[$] = [1,2,3,4];, but since we can't do that, this is almost certainly a bug at every location.
I just searched through my code for cases of this (I have a lot of tables), and found 3 actual real cases of actual bugs from this. (!)

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