google / google/closure-compiler
Different behavior when inlining anonymous functions?
Open
OTI
P3
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
I use ADVANCED optimization and I expect both scripts to raise a warning because of bad callFn argument.
This script raises a warning:
``` javascript
/**
* @param {function(number)} fn
*/
function callFn(fn) {
fn(1);
};
var fnToCall = function (/** !Function */ arg) {
console.log(arg);
};
callFn(fnToCall);
```
This does not (fnToCall inlined):
``` javascript
/**
* @param {function(number)} fn
*/
function callFn(fn) {
fn(1);
};
callFn(function fnToCall(/** !Function */ arg) {
console.log(arg);
});
```
Contributor guide
Assessment
This issue has not been assessed yet.