Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add diagnostics error for template var assignment issue #33674

Closed
kara opened this issue Nov 7, 2019 · 2 comments
Closed

Add diagnostics error for template var assignment issue #33674

kara opened this issue Nov 7, 2019 · 2 comments

Comments

@kara
Copy link
Contributor

@kara kara commented Nov 7, 2019

If you try to assign a value to a template var, we should give you an error with a squiggly that points you to where the invalid assignment is.

@ngbot ngbot bot modified the milestone: Backlog Nov 7, 2019
@kara kara modified the milestones: Backlog, v9-candidates Nov 7, 2019
@alxhub alxhub added this to Backlog in Compiler via automation Nov 7, 2019
@kara kara modified the milestones: v9-candidates, v9-blockers Nov 18, 2019
@JoostK JoostK assigned JoostK and unassigned alxhub Dec 7, 2019
@kara

This comment has been minimized.

Copy link
Contributor Author

@kara kara commented Dec 11, 2019

@kara kara added the state: has PR label Dec 11, 2019
alxhub added a commit to alxhub/angular that referenced this issue Dec 12, 2019
In Ivy it's illegal for a template to write to a template variable. So the
template:

```html
<ng-template let-somevar>
  <button (click)="somevar = 3">Set var to 3</button>
</ng-template>
```

is erroneous and previously would fail to compile with an assertion error
from the `TemplateDefinitionBuilder`. This error wasn't particularly user-
friendly, though, as it lacked the context of which template or where the
error occurred.

In this commit, a new check in template type-checking is added which detects
such erroneous writes and produces a true diagnostic with the appropriate
context information.

Closes angular#33674
@kara kara closed this in 6ba5fdc Dec 12, 2019
kara added a commit that referenced this issue Dec 12, 2019
In Ivy it's illegal for a template to write to a template variable. So the
template:

```html
<ng-template let-somevar>
  <button (click)="somevar = 3">Set var to 3</button>
</ng-template>
```

is erroneous and previously would fail to compile with an assertion error
from the `TemplateDefinitionBuilder`. This error wasn't particularly user-
friendly, though, as it lacked the context of which template or where the
error occurred.

In this commit, a new check in template type-checking is added which detects
such erroneous writes and produces a true diagnostic with the appropriate
context information.

Closes #33674

PR Close #34339
@angular-automatic-lock-bot

This comment has been minimized.

Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Jan 12, 2020

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Compiler
Backlog
3 participants
You can’t perform that action at this time.