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

[Bug]: yield* with async function as Symbol.iterator #6400

Open
p51lee opened this issue Nov 10, 2022 · 0 comments
Open

[Bug]: yield* with async function as Symbol.iterator #6400

p51lee opened this issue Nov 10, 2022 · 0 comments
Labels

Comments

@p51lee
Copy link

p51lee commented Nov 10, 2022

Describe the bug

Input code is expected to throw TypeError but the output code is terminated normally.

Input code

[ ... function * ( ) { yield * { [ Symbol . iterator ] : async x => 0 } ; } ( ) ] ;

Config

No response

Playground link

https://play.swc.rs/?version=1.3.14&code=H4sIAAAAAAAAAxWLMQqAIAAAv3JjNUhzUZ9oFAczA8EUzCCJ%2Fp4NB3fDSYQQ7Fcw2cVAR0PLQ3HWb7UeJEs51ugRuGyTzjGhGNBnCYabaabnZaz8q6r2ARhViXpUAAAA&config=H4sIAAAAAAAAA0WMTQrEIAxG75K1286id5hDBCctFv9IUhgR714tlu7C915ehUMsrBUyshCPS0pU%2FMMKZAOKZZcVTNf6tKEXagYUeScdiiyd%2BZSEJjUQXHRbGSWbQmYSeRHG3T9m66GQfucYKmjJdAc%2F0N7G%2FHPynaLySe0Cj9ke9LUAAAA%3D

Expected behavior

TypeError is expected:

$ node input.js
input.js:1
[ ... function * ( ) { yield * { [ Symbol . iterator ] : async x => 0 } ; } ( ) ] ;
                                                           ^

TypeError: undefined is not a function
    at input.js:1:60
    at Generator.next (<anonymous>)
    at Object.<anonymous> (input.js:1:79)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Node.js v18.11.0

Actual behavior

Output code is terminated normally:

$ node output.js # no error

Version

1.3.14 (default SWC playground)

Additional context

Perhaps changing async function (async x => 0) into a generator function may have deleted TypeError.

@p51lee p51lee added the C-bug label Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant