Skip to content

SyntaxError when defining Async Generators in Basilisp #1180

@ikappaki

Description

@ikappaki

Hi,

there appears to be an issue when trying to define an async generator in Basilisp:
SyntaxError: 'return' with value in async generator

To reproduce:

  • Open the REPL and try to define an async generator that yield values, the above error is thrown
> basilisp repl
basilisp.user=> (defasync agen
                  []
                  (dotimes [i 5]
                    (yield i)))
Traceback (most recent call last):
  File "C:\src\basilisp\src\basilisp\cli.py", line 583, in repl
    result = eval_str(lsrc, ctx, ns, eof)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\src\basilisp\src\basilisp\cli.py", line 54, in eval_str
    last = compiler.compile_and_exec_form(form, ctx, ns)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\src\basilisp\src\basilisp\lang\compiler\__init__.py", line 186, in compile_and_exec_form
    bytecode = compile(ast_module, ctx.filename, "exec")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<REPL Input>", line 1
SyntaxError: 'return' with value in async generator

The above example works correctly outside an async context

> basilisp repl
basilisp.user=> (defn gen
                  []
                  (dotimes [i 5]
                    (yield i)))
#'basilisp.user/gen

basilisp.user=> (vec (gen))
[0 1 2 3 4]

Thanks

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions