Skip to content

Can't declare empty arrays #982

@skyrpex

Description

@skyrpex

I tried this

Tried creating empty arrays, using both automatically inferred types and explicitly defining the types.

let x: Array<num> = [];
let y = [];

Expected

let x: Array<num> = [];

The code above should work as is.

let x = [];

The code above should, maybe, infer an array of anys.

Instead, this happened

There was a compilation error:

Compilation failed with 2 errors
Error at code.w:1:21 | Cannot infer type of empty array
Error at code.w:2:9 | Cannot infer type of empty array

Component

Compiler

Environment

- Wing Version: 0.4.26
- OS: MacOS
- Node version: 18.12.1

Sub tasks

  • let x: Array<num> = []; should compile correctly
  • let arr = new Array<num>(); should compile correctly

Metadata

Metadata

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions