stc icon indicating copy to clipboard operation
stc copied to clipboard

Use iterator for spread args

Open kdy1 opened this issue 2 years ago • 1 comments

https://github.com/dudykr/stc/blob/798c322abf94b8353feb4f4022185b932069f5e1/crates/stc_ts_type_checker/tests/conformance/es6/spread/iteratorSpreadInCall2.ts#L1-L16

should pass, but stc fails with

thread 'conformance::es6::spread::iteratorSpreadInCall2.ts' panicked at '
============================================================
error[TS2345]: DebugContext(
    context: arg is spread
    context:
    lhs = instanceof  symbol[];
    rhs = symbol;
    context: `fail!()` called from assign/mod.rs:1490
    WrongArgType {
        span: Span {
            lo: BytePos(
                234,
            ),
            hi: BytePos(
                252,
            ),
            ctxt: #0,
        },
        inner: AssignFailed {
            span: Span {
                lo: BytePos(
                    234,
                ),
                hi: BytePos(
                    252,
                ),
                ctxt: #0,
            },
            cause: [],
        },
    },
)
  --> $DIR/tests/conformance/es6/spread/iteratorSpreadInCall2.ts:16:8
   |
16 | foo(...new SymbolIterator);
   |        ^^^^^^^^^^^^^^^^^^


    ============================================================
1 unmatched errors out of 1 errors. Got 1 extra errors.
Wanted: [RefError { line: 16, column: 5, code: "TS2556" }]
Unwanted: [(16, "TS2345")]', crates/stc_ts_type_checker/tests/tsc.rs:756:17

Solution (guess)

We should use functions related to iterator, like get_iterator_element_type instead of

https://github.com/dudykr/stc/blob/798c322abf94b8353feb4f4022185b932069f5e1/crates/stc_ts_file_analyzer/src/analyzer/expr/call_new.rs#L2904-L2912

kdy1 avatar Nov 08 '22 05:11 kdy1

Made an attempt here. Would appreciate any feedback!

cmrigney avatar Nov 09 '22 04:11 cmrigney