Skip to content

Emit a diagnostic when using a type as a value #1860

@saulecabrera

Description

@saulecabrera

Currently, when using a type as a value, the compiler hits an assert. It should instead emit a diagnostic.

Example

class A {
  a: i32 = 1;
}


function id<T>(p: T): T {
  return p;
}

export function add(): void {
  id<A>({a: i32}); // Note the use of i32
}

Expected
Something similar to:

'i32' only refers to a type, but is being used as a value here.

Actual

Assert

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions