This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 270660 - Wrong warning for unused variable in ES6 module with `export default`
Summary: Wrong warning for unused variable in ES6 module with `export default`
Status: NEW
Alias: None
Product: javascript
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 8.2
Hardware: PC Windows 10 x64
: P3 normal (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-17 09:24 UTC by tricki
Modified: 2017-05-17 09:24 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tricki 2017-05-17 09:24:29 UTC
In the following code NetBeans wrongly flags `defaults` as an unused variable.

    export default (function(){
        const Module = function () {

            var defaults = {
                prop: 'value'
            };

            this.options = defaults;

            return this;
        };

    })();

The bug disappears when I change the first line to anything other than `export default` (e.g. `export const Module` or `return const Module`).

Other connected features also don't work, like renaming.

A workaround is to first define a variable and then export it:

    const Module = (function(){
        const Module = function () {

            var defaults = {
                prop: 'value'
            };

            this.options = defaults;

            return this;
        };

    })();

    export default Module;

Product Version: NetBeans IDE 8.2 (Build 201609300101)
Updates: NetBeans IDE is updated to version NetBeans 8.2 Patch 1
Java: 1.8.0_101; Java HotSpot(TM) 64-Bit Server VM 25.101-b13
Runtime: Java(TM) SE Runtime Environment 1.8.0_101-b13
System: Windows 10 version 10.0 running on amd64; Cp1252; en_US (nb)