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

REPL can't run (some?) generators with yield in the Civet code #1659

Closed
nicholaides opened this issue Dec 24, 2024 · 0 comments · Fixed by #1662
Closed

REPL can't run (some?) generators with yield in the Civet code #1659

nicholaides opened this issue Dec 24, 2024 · 0 comments · Fixed by #1662
Labels
bug Something isn't working

Comments

@nicholaides
Copy link

Problem exists in the playground and the REPL (npx civet).

This code:

do* yield 1

Correctly compiles to this JavaScript:

(function*(){{ yield 1 }})()

But when run in the REPL, errors like this:

🐱> do* yield 1
... 
REPL2:1
(yield* (function*(){(function*(){{ yield 1 }})()})())
^

Uncaught ReferenceError: yield is not defined
    at REPL2:1:1
    at Script.runInContext (node:vm:149:12)
    at Module.runInContext (node:vm:301:6)
    at REPLServer.eval (/Users/mike/WIP/vite-civet/my-vue-app/node_modules/@danielx/civet/dist/civet:424:23)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)

On the playground it shows the same message, but without the backtrace.

Other code that has the same issue:

// ❌ errors
n := for* item of [1,2,3]
  yield 1
  item
// ✅ works
n := for* item of [1,2,3]
  item
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants