Skip to content

New optional array access operator may fail on compilation with nil arrays #591

@yoavj-arpeely

Description

@yoavj-arpeely

If the compiler knows a variable is nil, the (very cool!) ?.[] operator fails.
Examples:
The following expression fails on compilation:

let arr = nil;
arr?.[3]

The error is:
type <nil>[int] is undefined (4:6)

This one, however, succeed:

let x = 3;
let arr = x < 4 ? nil : [1];
arr?.[0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions