-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Closed
Closed
Copy link
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilerbugcore: control flowIssues related to the built-in control flow (@if, @for, @switch)Issues related to the built-in control flow (@if, @for, @switch)hotlist: error messagesstate: has PR
Milestone
Description
Which @angular/* package(s) are the source of the bug?
compiler
Is this a regression?
No
Description
Writing the following in a template: @for (item of items; track ) will result in the cryptic compilation error:
✘ [ERROR] Angular compilation emit failed. [plugin angular-compiler]
Error: AssertionError: Unsupported reification of ir.Expression kind: EmptyExpr
at reifyIrExpression (file:///Users/pkozlowski/trash/ng-track-by/node_modules/@angular/compiler/fesm2022/compiler.mjs:22452:19)
at transformExpressionsInExpression (file:///Users/pkozlowski/trash/ng-track-by/node_modules/@angular/compiler/fesm2022/compiler.mjs:10647:12)
at transformExpressionsInOp (file:///Users/pkozlowski/trash/ng-track-by/node_modules/@angular/compiler/fesm2022/compiler.mjs:10489:24)
at reifyCreateOperations (file:///Users/pkozlowski/trash/ng-track-by/node_modules/@angular/compiler/fesm2022/compiler.mjs:22136:9)
at Object.reify [as fn] (file:///Users/pkozlowski/trash/ng-track-by/node_modules/@angular/compiler/fesm2022/compiler.mjs:22105:9)
at transform (file:///Users/pkozlowski/trash/ng-track-by/node_modules/@angular/compiler/fesm2022/compiler.mjs:24249:19)
at compileComponentFromMetadata (file:///Users/pkozlowski/trash/ng-track-by/node_modules/@angular/compiler/fesm2022/compiler.mjs:30764:9)
at ComponentDecoratorHandler.compileFull (file:///Users/pkozlowski/trash/ng-track-by/node_modules/@angular/compiler-cli/bundles/chunk-WYZJV3LZ.js:7628:17)
at TraitCompiler.compile (file:///Users/pkozlowski/trash/ng-track-by/node_modules/@angular/compiler-cli/bundles/chunk-WYZJV3LZ.js:2618:38)
at IvyCompilationVisitor.visitClassDeclaration (file:///Users/pkozlowski/trash/ng-track-by/node_modules/@angular/compiler-cli/bundles/chunk-WYZJV3LZ.js:2958:37)
For 17.2 and the previous template compilation pipeline we got a different, but equally cryptic error:
TypeError: Cannot read properties of undefined (reading 'visit')
at convertPureComponentScopeFunction (file:///home/projects/stackblitz-starters-vlsqkz/node_modules/@angular/compiler/fesm2022/compiler.mjs:7370:33)
at TemplateDefinitionBuilder.createTrackByFunction (file:///home/projects/stackblitz-starters-vlsqkz/node_modules/@angular/compiler/fesm2022/compiler.mjs:29677:23)
at TemplateDefinitionBuilder.visitForLoopBlock (file:///home/projects/stackblitz-starters-vlsqkz/node_modules/@angular/compiler/fesm2022/compiler.mjs:29546:109)
at ForLoopBlock.visit (file:///home/projects/stackblitz-starters-vlsqkz/node_modules/@angular/compiler/fesm2022/compiler.mjs:4281:24)
at visitAll$1 (file:///home/projects/stackblitz-starters-vlsqkz/node_modules/@angular/compiler/fesm2022/compiler.mjs:4467:34)
at TemplateDefinitionBuilder.buildTemplateFunction (file:///home/projects/stackblitz-starters-vlsqkz/node_modules/@angular/compiler/fesm2022/compiler.mjs:28541:9)
at Module.compileComponentFromMetadata (file:///home/projects/stackblitz-starters-vlsqkz/node_modules/@angular/compiler/fesm2022/compiler.mjs:30970:60)
at ComponentDecoratorHandler.compileFull (file:///home/projects/stackblitz-starters-vlsqkz/node_modules/@angular/compiler-cli/bundles/chunk-LVVK56VK.js:7660:35)
at TraitCompiler.compile (file:///home/projects/stackblitz-starters-vlsqkz/node_modules/@angular/compiler-cli/bundles/chunk-LVVK56VK.js:2673:38)
at IvyCompilationVisitor.visitClassDeclaration (file:///home/projects/stackblitz-starters-vlsqkz/node_modules/@angular/compiler-cli/bundles/chunk-LVVK56VK.js:3013:37)
Instead, we should detect those situations earlier and report the same / similar error as missing track keyword.
Interestingly the same applies to the language service where the described situation is not reported.
Please provide a link to a minimal reproduction of the bug
Please provide the exception or error you saw
No response
Please provide the environment you discovered this bug in (run ng version)
No response
Anything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: compilerIssues related to `ngc`, Angular's template compilerIssues related to `ngc`, Angular's template compilerbugcore: control flowIssues related to the built-in control flow (@if, @for, @switch)Issues related to the built-in control flow (@if, @for, @switch)hotlist: error messagesstate: has PR