From 023e0cc01753b965df67c668b461bf9af63cd7c9 Mon Sep 17 00:00:00 2001 From: Bolun Thompson Date: Sun, 5 Jan 2025 10:11:00 -0800 Subject: [PATCH] Fix typo in compile_asts (#740) * Fix typo Signed-off-by: Bolun Thompson * Add check that compile_ast result is an IR Signed-off-by: Bolun Thompson * Add return type hint to compile_node Signed-off-by: Bolun Thompson --------- Signed-off-by: Bolun Thompson --- compiler/ast_to_ir.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/compiler/ast_to_ir.py b/compiler/ast_to_ir.py index c1e753fa3..0d9a84220 100644 --- a/compiler/ast_to_ir.py +++ b/compiler/ast_to_ir.py @@ -100,23 +100,19 @@ def compile_asts(ast_objects: "list[AstNode]", fileIdGen, config): if isinstance(compiled_ast, IR): acc_ir.background_union(compiled_ast) else: - ## TODO: Make this union the compiled_ast with the - ## accumulated IR, since the user wanted to run these - ## commands in parallel (Is that correct?) - # acc_ir.background_union(IR([compiled_ast])) - compiled_asts.append(acc_ir) - acc_it = None - compiled_asts.append(compiled_ast) + ## shouldn't happen since compile_node should have already + ## raised this error + raise UnparallelizableError(f"Node: {compiled_ast} is not pure") ## If the current compiled ast not in background (and so ## the union isn't in background too), stop accumulating - if not acc_ir is None and not acc_ir.is_in_background(): + if not acc_ir.is_in_background(): compiled_asts.append(acc_ir) acc_ir = None else: ## If the compiled ast is in background, start ## accumulating it - if isinstance(compiled_ast, IR) and compiled_ast.is_in_background(): + if compiled_ast.is_in_background(): acc_ir = compiled_ast else: compiled_asts.append(compiled_ast) @@ -128,7 +124,7 @@ def compile_asts(ast_objects: "list[AstNode]", fileIdGen, config): return compiled_asts -def compile_node(ast_object, fileIdGen, config): +def compile_node(ast_object, fileIdGen, config) -> IR: global compile_cases return ast_match(ast_object, compile_cases, fileIdGen, config)