diff options
| author | Kenny <3454741+WarriorOfWire@users.noreply.github.com> | 2020-07-21 22:43:15 -0700 |
|---|---|---|
| committer | Kenny <3454741+WarriorOfWire@users.noreply.github.com> | 2020-07-24 19:47:34 -0700 |
| commit | 9a1f1236ccf9fd525675b8b8ea34178851f968cc (patch) | |
| tree | d680c8ea4c1fd4d965a9d8c4c161c9b067625ece /py/compile.c | |
| parent | a6e048686fe6999c4231582b7d9e69a7dc679257 (diff) | |
require async for and async with to actually be in an async def method instead of just a generator
Diffstat (limited to 'py/compile.c')
| -rw-r--r-- | py/compile.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/py/compile.c b/py/compile.c index 9b0d29998..fade4c01a 100644 --- a/py/compile.c +++ b/py/compile.c @@ -1713,11 +1713,11 @@ STATIC void compile_yield_from(compiler_t *comp) { #if MICROPY_PY_ASYNC_AWAIT STATIC bool compile_require_async_context(compiler_t *comp, mp_parse_node_struct_t *pns) { int scope_flags = comp->scope_cur->scope_flags; - if(scope_flags & MP_SCOPE_FLAG_GENERATOR) { + if(scope_flags & MP_SCOPE_FLAG_ASYNC) { return true; } compile_syntax_error(comp, (mp_parse_node_t)pns, - translate("'async for' or 'async with' outside async function")); + translate("'await', 'async for' or 'async with' outside async function")); return false; } @@ -2645,6 +2645,7 @@ STATIC void compile_atom_expr_await(compiler_t *comp, mp_parse_node_struct_t *pn compile_syntax_error(comp, (mp_parse_node_t)pns, translate("'await' outside function")); return; } + compile_require_async_context(comp, pns); compile_atom_expr_normal(comp, pns); compile_yield_from(comp); } |
