Skip to content

statement in @if behind as not marked as error by compiler #59939

@sod

Description

@sod

I had the pleasure to code review this today:

    <!-- part of a component template: -->
    @if (foo; as var && !bar) {
      if is true
    }

This was a result of copy/pasta and trying to modify it. The suspect thought, that !bar was part of the condition and didn't notice the as var in between.

Expected:

  • angular compiler error: var && !bar invalid after as
  • angular warning: var unused

Actual:

  • no warnings at all

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/bolt-angular-pwljvmk3?file=src%2Fmain.ts

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: compilerIssues related to `ngc`, Angular's template compilerbugcompiler: parsercore: control flowIssues related to the built-in control flow (@if, @for, @switch)

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions