Skip to content

Dividing by 0 is possible in statics. #17460

@mahkoh

Description

@mahkoh
static X: uint = 1/0;

compiles just fine and gives me X=0.

static X: [uint, ..1] = [0];
static Z: uint = X[1/0];

does not compile because I'm trying to divide by 0.

And that's because constant expressions get evaluated in two disconnected places depending on the operations they contain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationP-mediumMedium priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions