Bugfix: @for parser fails on signal accessors like items() because )...
Documentation for Sessions
🐛 Bugfix: @for parser fails on signal accessors like items() because )...
Date: 2026-03-24
Time: 19:40:29 UTC
Session: gspace1-264.6
Agent: angular
Confidence: 98%
Status: ✅ Documented
📋 Decision Context
Question:
@for parser fails on signal accessors like items() because ) in items() is treated as end of @for expression
Task: S264.4: Fix @for parser paren-depth bug
🎯 Decision Made
Chosen:
Add parenthesis depth tracking to @for collection and track expression readers
Options Considered:
- Option A: Escape parens in collection expressions (wrong — changes semantics)
- Option B: Track paren depth in reader loops (chosen — correct and simple)
- Option C: Pre-process template to normalize signal calls (unnecessary complexity)
💭 Reasoning
Root cause: The @for block parser reads the collection expression with a simple while loop that breaks on ')' or ';'. But Angular signals use method-call syntax like items(), and the ')' in items() was interpreted as the closing ')' of @for (...). Fix: Track parenDepth — increment on '(', decrement on ')'. Only break on ')' when depth is 0 (the actual @for closing paren). Same fix applied to track expression reader. This is critical because virtually ALL generated code uses signals (items(), title(), etc.) per our coding standards.
📁 Files Involved
libs/libs-structural/platform-preview/src/lib/compiler/template-parser.ts
🔗 Related
- Decision ID:
dev_1774381229041_gr1euu9 - Session: 264
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation