Fix conditional branch rendering: append children to wrapper
**Bug:** Conditional branches (match/case) rendered empty content.
- Tabs would switch but show no content in each tab
- Wrapper div was created but children never appended to it
**Root Cause:**
In `_emit_conditional_branch_function`, statements were rendered but
their return values were discarded:
```python
for stmt in body:
self._emit_statement(stmt) # ← return value ignored!
```
**Fix:**
Append returned elements to wrapper, just like `_emit_with` does:
```python
for stmt in body:
child_var = self._emit_statement(stmt)
if child_var:
self.lines.append(f"call void @js_append_child(i32 %{wrapper_var}, i32 %{child_var})")
```
**LLVM Before:**
```llvm
%var87 = call i32 @js_create_element(...) ; wrapper
%var89 = call i32 @js_create_element(...) ; content
; ... build var89's children ...
ret i32 %var87 ; ← var89 never appended!
```
**LLVM After:**
```llvm
%var87 = call i32 @js_create_element(...) ; wrapper
%var89 = call i32 @js_create_element(...) ; content
; ... build var89's children ...
call void @js_append_child(i32 %var87, i32 %var89) ; ← FIX!
ret i32 %var87
```
**Result:**
✅ Tabs example now shows content in each tab
✅ Vertical tabs (nested conditionals) also work
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
0b77c2ff3c
commit
7efa7786cf
4 files changed
+12
-1
No files matched your search
Binary file not shown.
@@ -920,7 +920,10 @@ class SignalLLVMIRGenerator:
|
||||
|
||||
# Render all statements in the branch body
|
||||
for stmt in body:
|
||||
self._emit_statement(stmt)
|
||||
child_var = self._emit_statement(stmt)
|
||||
# Append top-level elements to wrapper
|
||||
if child_var:
|
||||
self.lines.append(f" call void @js_append_child(i32 %{wrapper_var}, i32 %{child_var})")
|
||||
|
||||
# Pop wrapper from parent stack
|
||||
self.parent_element_stack.pop()
|
||||
|
||||
Reference in new issue
Block a user