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

fix(compiler-cli): incorrectly type checking calls to implicit template variables #39686

Closed

Conversation

@crisbeto
Copy link
Member

@crisbeto crisbeto commented Nov 14, 2020

Currently when we encounter an implicit method call (e.g. {{ foo(1) }}) and we manage to resolve its receiver to something within the template, we assume that the method is on the receiver itself so we generate a type checking code to reflect it. This assumption is true in most cases, but it breaks down if the call is on an implicit receiver and the receiver itself is being invoked. E.g.

<div *ngFor="let fn of functions">{{ fn(1) }}</div>

These changes resolve the issue by generating a regular function call if the method call's receiver is pointing to $implicit.

Fixes #39634.

@google-cla google-cla bot added the cla: yes label Nov 14, 2020
@ngbot ngbot bot added this to the needsTriage milestone Nov 14, 2020
@crisbeto crisbeto marked this pull request as ready for review Nov 14, 2020
@pullapprove pullapprove bot requested a review from JoostK Nov 14, 2020
Copy link
Member

@petebacondarwin petebacondarwin left a comment

Nice work @crisbeto - it is great when things can be fixed so simply. Thanks for picking up this issue and resolving it so quickly.

@crisbeto crisbeto force-pushed the 39634/type-check-implicit-calls branch from 46e6cec to 3a29804 Nov 15, 2020
JoostK
JoostK approved these changes Nov 15, 2020
…te variables

Currently when we encounter an implicit method call (e.g. `{{ foo(1) }}`) and we manage to resolve
its receiver to something within the template, we assume that the method is on the receiver itself
so we generate a type checking code to reflect it. This assumption is true in most cases, but it
breaks down if the call is on an implicit receiver and the receiver itself is being invoked. E.g.

```
<div *ngFor="let fn of functions">{{ fn(1) }}</div>
```

These changes resolve the issue by generating a regular function call if the method call's receiver
is pointing to `$implicit`.

Fixes angular#39634.
atscott added a commit that referenced this issue Nov 16, 2020
…te variables (#39686)

Currently when we encounter an implicit method call (e.g. `{{ foo(1) }}`) and we manage to resolve
its receiver to something within the template, we assume that the method is on the receiver itself
so we generate a type checking code to reflect it. This assumption is true in most cases, but it
breaks down if the call is on an implicit receiver and the receiver itself is being invoked. E.g.

```
<div *ngFor="let fn of functions">{{ fn(1) }}</div>
```

These changes resolve the issue by generating a regular function call if the method call's receiver
is pointing to `$implicit`.

Fixes #39634.

PR Close #39686
@atscott atscott closed this in a61fe96 Nov 16, 2020
@angular-automatic-lock-bot
Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Dec 17, 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 Dec 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.