@@ -385,35 +385,47 @@ impl Compiler {
385385 }
386386 self . set_label ( end_label) ;
387387 }
388- With { items, body } => {
389- let end_label = self . new_label ( ) ;
390- for item in items {
391- self . compile_expression ( & item. context_expr ) ?;
392- self . emit ( Instruction :: SetupWith { end : end_label } ) ;
393- match & item. optional_vars {
394- Some ( var) => {
395- self . compile_store ( var) ?;
396- }
397- None => {
398- self . emit ( Instruction :: Pop ) ;
388+ With {
389+ is_async,
390+ items,
391+ body,
392+ } => {
393+ if * is_async {
394+ unimplemented ! ( "async with" ) ;
395+ } else {
396+ let end_label = self . new_label ( ) ;
397+ for item in items {
398+ self . compile_expression ( & item. context_expr ) ?;
399+ self . emit ( Instruction :: SetupWith { end : end_label } ) ;
400+ match & item. optional_vars {
401+ Some ( var) => {
402+ self . compile_store ( var) ?;
403+ }
404+ None => {
405+ self . emit ( Instruction :: Pop ) ;
406+ }
399407 }
400408 }
401- }
402409
403- self . compile_statements ( body) ?;
404- for _ in 0 ..items. len ( ) {
405- self . emit ( Instruction :: CleanupWith { end : end_label } ) ;
410+ self . compile_statements ( body) ?;
411+ for _ in 0 ..items. len ( ) {
412+ self . emit ( Instruction :: CleanupWith { end : end_label } ) ;
413+ }
414+ self . set_label ( end_label) ;
406415 }
407- self . set_label ( end_label) ;
408416 }
409417 For {
418+ is_async,
410419 target,
411420 iter,
412421 body,
413422 orelse,
414- } => self . compile_for ( target, iter, body, orelse) ?,
415- AsyncFor { .. } => {
416- unimplemented ! ( "async for" ) ;
423+ } => {
424+ if * is_async {
425+ unimplemented ! ( "async for" ) ;
426+ } else {
427+ self . compile_for ( target, iter, body, orelse) ?
428+ }
417429 }
418430 Raise { exception, cause } => match exception {
419431 Some ( value) => {
@@ -439,14 +451,18 @@ impl Compiler {
439451 finalbody,
440452 } => self . compile_try_statement ( body, handlers, orelse, finalbody) ?,
441453 FunctionDef {
454+ is_async,
442455 name,
443456 args,
444457 body,
445458 decorator_list,
446459 returns,
447- } => self . compile_function_def ( name, args, body, decorator_list, returns) ?,
448- AsyncFunctionDef { .. } => {
449- unimplemented ! ( "async def" ) ;
460+ } => {
461+ if * is_async {
462+ unimplemented ! ( "async def" ) ;
463+ } else {
464+ self . compile_function_def ( name, args, body, decorator_list, returns) ?
465+ }
450466 }
451467 ClassDef {
452468 name,
0 commit comments