Commit 6d3db45
committed
fix: Prioritize channel receive detection over type hoisting
Fixed critical bug where channel receive variables (currentState := <-channel)
were incorrectly treated as hoisted variables instead of channel receives.
Root cause:
- inferTypeFromExpr returns the element type for channel receives
- analyzeComponentBody checked inferredType != nil BEFORE checking hasChannelOp
- Since both were true, it took the hoisted vars branch and skipped channel tracking
- This caused g.channelReceiveVars to be empty
- Result: No channel listeners were generated, breaking reactive updates
Fix:
1. Reorder checks in analyzeComponentBody to check hasChannelOp FIRST
2. Reorder checks in generateBody for consistency
3. Skip channel receive vars when adding struct fields
Now works correctly:
- Channel receives tracked in channelReceiveVars map
- Listeners generated for channels that are received from
- Local variables created in Render from struct fields
- Calculator and other examples with channel-based state now work
Testing:
- All codegen tests pass
- Calculator buttons update state correctly
- WebGPU cube controls update reactively1 parent b8b1588 commit 6d3db45
4 files changed
Lines changed: 57 additions & 55 deletions
File tree
- examples
- calculator
- webgpu-cube
- pkg/codegen
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
This file was deleted.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
374 | | - | |
375 | | - | |
376 | | - | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
377 | 379 | | |
378 | 380 | | |
379 | 381 | | |
| 382 | + | |
| 383 | + | |
380 | 384 | | |
381 | 385 | | |
382 | 386 | | |
| |||
970 | 974 | | |
971 | 975 | | |
972 | 976 | | |
| 977 | + | |
973 | 978 | | |
974 | 979 | | |
975 | 980 | | |
976 | 981 | | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
977 | 987 | | |
978 | 988 | | |
979 | 989 | | |
| |||
1540 | 1550 | | |
1541 | 1551 | | |
1542 | 1552 | | |
1543 | | - | |
1544 | | - | |
1545 | | - | |
1546 | | - | |
1547 | | - | |
1548 | | - | |
| 1553 | + | |
1549 | 1554 | | |
1550 | 1555 | | |
1551 | 1556 | | |
1552 | 1557 | | |
1553 | | - | |
1554 | | - | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
1555 | 1581 | | |
1556 | 1582 | | |
1557 | 1583 | | |
| |||
0 commit comments