kaleidawave / ezno

A fast and correct TypeScript type checker and compiler with additional experiments
https://kaleidawave.github.io/posts/introducing-ezno/
MIT License
2.55k stars 47 forks source link

Constructor calls with generic type argument don't parse correctly #199

Closed kaleidawave closed 2 months ago

kaleidawave commented 2 months ago

Given

const y = new Y<3>(3);

It parses as something like:

expression: ConstructorCall {
    constructor: FunctionCall {
        function: VariableReference(
            "Y",
            1003..1004,
        ),
        type_arguments: Some(
            [
                NumberLiteral(
                    Number(
                        3.0,
                    ),
                    1005..1006,
                ),
            ],
        ),
        arguments: [
            Standard(
                NumberLiteral(
                    Number(
                        3.0,
                    ),
                    1008..1009,
                ),
            ),
        ],
        is_optional: false,
        position: 1003..1010,
    },
    type_arguments: None,
    arguments: None,
    position: 999..1010,
},

Something around here (or possibly return precedence) is broken when type arguments show up

https://github.com/kaleidawave/ezno/blob/e69e2c5acfe40b1cfa2150f0bde74df82edccc48/parser/src/expressions/mod.rs#L471-L507