google / google/closure-compiler

Property get/set on null/undefined should fail

Open
#2,850 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.7k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
6

Description

Given:

```js
/** @param {null} name */
function hello(name) {
alert(name.x);
}
hello(null);
```

I expect there to be an error on line 3 since you cannot do `ToObject` on `null`/`undefined`.

This might need a per file/project setting to make it easier to transition to it.

https://closure-compiler.appspot.com/home#code%3D%252F%252F%2520%253D%253DClosureCompiler%253D%253D%250A%252F%252F%2520%2540compilation_level%2520ADVANCED_OPTIMIZATIONS%250A%252F%252F%2520%2540output_file_name%2520default.js%250A%252F%252F%2520%2540formatting%2520pretty_print%250A%252F%252F%2520%253D%253D%252FClosureCompiler%253D%253D%250A%250A%252F**%2520%2540param%2520%257Bnull%257D%2520name%2520*%252F%250Afunction%2520hello(name)%2520%257B%250A%2520%2520alert(name.x)%253B%250A%257D%250Ahello(null)%253B%250A%250A

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.