Skip to content

Commit 0df19dc

Browse files
BloggerBustjayanth-kumar-morem
authored andcommitted
fix(renderer): prevent crash when lifting display renderer as raw ast.Call
Fixes a bug where implicit rendering failed due to an unhandled AST node type. Adds support for handling `ast.Call` nodes directly in `_build_atom_function`, allowing display renderer calls to be safely lifted even when not wrapped in an `ast.Expr`. Also adds a guard in `_finalize_and_register_atom` to skip further processing if the atom function could not be constructed. This prevents runtime crashes when `_build_atom_function` returns `None`.
1 parent f4bf3f9 commit 0df19dc

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

preswald/engine/transformers/reactive_runtime.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,9 @@ def _finalize_and_register_atom(
483483
callsite_node: ast.AST | None = None,
484484
) -> ast.FunctionDef:
485485
func = self._build_atom_function(atom_name, component_id, callsite_deps, call_expr, return_target=return_target, callsite_node=callsite_node)
486-
self._finalize_atom_deps(func)
487-
self._current_frame.generated_atoms.append(func)
486+
if func is not None:
487+
self._finalize_atom_deps(func)
488+
self._current_frame.generated_atoms.append(func)
488489
return func
489490

490491
def _should_inline_function(self, func_name: str) -> bool:
@@ -2482,6 +2483,8 @@ def _build_atom_function(
24822483
body = call_expr
24832484
elif isinstance(call_expr, ast.Assign) or isinstance(call_expr, ast.Expr):
24842485
body = [call_expr]
2486+
elif isinstance(call_expr, ast.Call):
2487+
body = [ast.Expr(value=call_expr)]
24852488
else:
24862489
self._safe_register_error(
24872490
node=call_expr,

0 commit comments

Comments
 (0)