apache / apache/netbeans

[JS] Incorrect highlighting of unused variable

Open
#6,108 0 comments 0 reactions 0 assignees View on GitHub
JavaScript kind:bug needs:triage
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 18

### What happened

Example code:

```js
class Foo {
bar(options = {}) {
const callback = options.callback || (() => true);
callback();
}
}
```

In line 3 variable `callback` highlighted as unused variable, however there is a usage right on next line.

### How to reproduce

_No response_

### Did this work correctly in an earlier version?

No / Don't know

### Operating System

Windows 10

### JDK

16.0.1

### Apache NetBeans packaging

Apache NetBeans provided installer

### Anything else

_No response_

### Are you willing to submit a pull request?

No

Contributor guide

Open the contributing guide

Research direction

Reproduce the example in the NetBeans 18 JavaScript editor on Windows 10 and inspect how the `callback` declaration and its next-line invocation are analyzed. Done means the variable is no longer highlighted as unused when it is called.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.