Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow more return types for async generators #787

Open
Tracked by #1074
kdy1 opened this issue Mar 4, 2023 · 8 comments
Open
Tracked by #1074

Allow more return types for async generators #787

kdy1 opened this issue Mar 4, 2023 · 8 comments
Labels
good first issue Good for newcomers

Comments

@kdy1
Copy link
Member

kdy1 commented Mar 4, 2023

Test case

async function * explicitReturnType16(): {} {
yield 1;
}

We should modify the logic to avoid assigning to the declared return type if a yield expression is in an async generator.

We can do it by checking if it's async iterable before assigning it from

let item_ty = if e.delegate {
if self.ctx.in_async {
self.get_async_iterator_element_type(e.span, Cow::Owned(ty))
.context("tried to convert argument as an async iterator for delegating yield")?
.into_owned()
} else {
self.get_iterator_element_type(e.span, Cow::Owned(ty), false, GetIteratorOpts { ..Default::default() })
.context("tried to convert argument as an iterator for delegating yield")?
.into_owned()
}
} else {
ty
}
.freezed();

@kdy1 kdy1 added the good first issue Good for newcomers label Mar 4, 2023
@kdy1 kdy1 added this to the v0.0.1: Correctness milestone Mar 4, 2023
@blacktoast
Copy link
Contributor

Can I try to fix it?

@kdy1
Copy link
Member Author

kdy1 commented Mar 9, 2023

Of course, thank you!

@kdy1
Copy link
Member Author

kdy1 commented Mar 23, 2023

@blacktoast Are you still willing to work on this?

@blacktoast
Copy link
Contributor

I've been working on it, but I've had a few things happen lately that have prevented me from progressing.

@kevinchua6
Copy link

Hi, I am struggling to run this specific test case. I have tried using ./scripts/test.sh asyncGenerators but it still runs all the test cases. I have also tried running ./scripts/fast.sh but it does not run that specific test case as well. I have tried ./scripts/errors/find-extra.sh TS2504 too but nothing came up on the console. I have also read contributing.md as well.

Please help! ><

@sunrabbit123
Copy link
Collaborator

sunrabbit123 commented Oct 6, 2023

Hi, I am struggling to run this specific test case. I have tried using ./scripts/test.sh asyncGenerators but it still runs all the test cases. I have also tried running ./scripts/fast.sh but it does not run that specific test case as well. I have tried ./scripts/errors/find-extra.sh TS2504 too but nothing came up on the console. I have also read contributing.md as well.

Please help! ><

can you excute ./scripts/test.sh types.asyncGenerators.es2018.1.ts?

I'll check it out when I get home
10 hours later?

@kevinchua6
Copy link

It works! But it runs all the other 5000 test cases which takes a long time. Is there a way to only run this specific test case?

Output:

     ,-[$DIR/tests/conformance/types/asyncGenerators/types.asyncGenerators.es2018.1.ts:118:1]
 118 | async function * explicitReturnType16(): {} {
 119 |     yield 1;
     :     ^^^^^^^
 120 | }
     `----

============================================================
0 unmatched errors out of 0 errors. Got 4 extra errors.
Wanted: []
Unwanted: [TscError { file: None, line: 31, col: 6, code: 2322 }, TscError { file: None, line: 46, col: 6, code: 2322 }, TscError { file: None, line: 61, col: 6, code: 2322 }, TscError { file: None, line: 119, col: 4, code: 2322 }]

All required errors: []
All actual errors: [TscError { file: None, line: 31, col: 6, code: 2322 }, TscError { file: None, line: 46, col: 6, code: 2322 }, TscError { file: None, line: 61, col: 6, code: 2322 }, TscError { file: None, line: 119, col: 4, code: 2322 }]
thread 'conformance::types::asyncGenerators::types.asyncGenerators.es2018.1.ts' panicked at 'explicit panic', crates/stc_ts_type_checker/tests/tsc.rs:530:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/c373194cb6d882dc455a588bcc29c92a96b50252/library/std/src/panicking.rs:578:5
   1: core::panicking::panic_fmt
             at /rustc/c373194cb6d882dc455a588bcc29c92a96b50252/library/core/src/panicking.rs:67:14
   2: core::panicking::panic
             at /rustc/c373194cb6d882dc455a588bcc29c92a96b50252/library/core/src/panicking.rs:117:5
   3: tsc::do_test
             at ./tests/tsc.rs:530:9
   4: tsc::create_test::{{closure}}::{{closure}}
             at ./tests/tsc.rs:220:17
   5: std::panicking::try::do_call
             at /rustc/c373194cb6d882dc455a588bcc29c92a96b50252/library/std/src/panicking.rs:485:40
   6: ___rust_try
   7: std::panicking::try
             at /rustc/c373194cb6d882dc455a588bcc29c92a96b50252/library/std/src/panicking.rs:449:19
   8: std::panic::catch_unwind
             at /rustc/c373194cb6d882dc455a588bcc29c92a96b50252/library/std/src/panic.rs:142:14
   9: tsc::create_test::{{closure}}
             at ./tests/tsc.rs:219:23
  10: core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /rustc/c373194cb6d882dc455a588bcc29c92a96b50252/library/core/src/ops/function.rs:250:5
  11: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/c373194cb6d882dc455a588bcc29c92a96b50252/library/alloc/src/boxed.rs:1985:9
  12: tsc::load_fixtures::{{closure}}
             at ./tests/tsc.rs:730:17
  13: core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /rustc/c373194cb6d882dc455a588bcc29c92a96b50252/library/core/src/ops/function.rs:250:5
  14: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/c373194cb6d882dc455a588bcc29c92a96b50252/library/alloc/src/boxed.rs:1985:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

test conformance has been running for over 60 seconds

failures:
    conformance::types::asyncGenerators::types.asyncGenerators.es2018.1.ts

test result: FAILED. 0 passed; 1 failed; 5631 ignored; 0 measured; 0 filtered out; finished in 38.48s

mimalloc: assertion failed: at "./mimalloc/src/segment.c":488, _mi_segment_thread_collect
  assertion: "tld->pages_reset.first == NULL"
error: test failed, to rerun pass `--test tsc`

Caused by:
  process didn't exit successfully: `/Users/kevinchua/Projects/stc/target/debug/deps/tsc-77c925a160f641b6 --quiet` (signal: 6, SIGABRT: process abort signal)
Notifying...

Sure, no problem! No rush haha

@sunrabbit123
Copy link
Collaborator

There is one way to do it

Copy the code and add it to the test case of stc_ts_file_analyzer, then run scripts/fast.sh(docs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Development

No branches or pull requests

4 participants