netbeans
netbeans copied to clipboard
Invalid error detection in Javascript syntax
Apache NetBeans version
Apache NetBeans 21
What happened
for (let i = 0; i < cellsInRange.length; i++)
{ let ci = cellsInRange[i];
if (!ci.cell.open)
{ let ims = ci.cell.getWallImages();
let data = [
{s:ci.sxydNW, i:ims[0]},//Bug in NetBeans!
{s:ci.sxydNE, i:ims[1]},//It says ims is an undeclared global
{s:ci.sxydSW, i:ims[2]},//OK in browser though
{s:ci.sxydSE, i:ims[3]}];
data.sort(function(a, b) {return b.s.d - a.s.d;}); // Descending distance
this.drawWall(data[1].s, data[3].s, data[1].i, ci.fogNo);
this.drawWall(data[2].s, data[3].s, data[2].i, ci.fogNo);
} }
Language / Project Type / NetBeans Component
HTML5/Javascript project (vanilla, for browser use)
How to reproduce
Did this work correctly in an earlier version?
Apache NetBeans 18
Operating System
WIndows 11 latest
JDK
JDK 11
Apache NetBeans packaging
Apache NetBeans provided installer
Anything else
Every time. If I change the let ims to var ims it is OK. The error is in NetBeans syntax checker.
Are you willing to submit a pull request?
No
Sorry - it did NOT work correctly in NB 18. That's what I was using when I found the problem. That prompted me to upgrade to 21 and the problem was still there. I have used NetBeans for many years without any such problems.
Lets reopen - I'll see what to do about this.
I should perhaps add that there is no other variable or property called ims that might be confusing things. Also that I have tested the code in FireFox, Edge, and the built-in WebKit browser and they all work fine, finding the variable ims as required.
This is not reproducible in current build:
Please check with the nightly build available here:
https://ci-builds.apache.org/job/Netbeans/job/netbeans-linux/lastSuccessfulBuild/artifact/nbbuild/
Please note:
- The ZIP in the referenced folder holds the ZIP Distribution of NetBeans. Expand it and you find a
netbeansfolder with the full installation. - You need at least JDK 17 to run NetBeans 22 (on my main machine and @work I'm on Amazon Corretto 21)
- If the JDK can't be automatically found, uncomment the line with the variable
netbeans_jdkhomein the filenetbeans/etc/netbeans.confand set the a path to the JDK there. On my windows test system for example it currently reads (with Amazon Corretto 17):
Tested with current master and this:
/* global cellsInRange */
for (let i = 0; i < cellsInRange.length; i++)
{ let ci = cellsInRange[i];
if (!ci.cell.open)
{ let ims = ci.cell.getWallImages();
let data = [
{s:ci.sxydNW, i:ims[0]},//Bug in NetBeans!
{s:ci.sxydNE, i:ims[1]},//It says ims is an undeclared global
{s:ci.sxydSW, i:ims[2]},//OK in browser though
{s:ci.sxydSE, i:ims[3]}];
data.sort(function(a, b) {return b.s.d - a.s.d;}); // Descending distance
this.drawWall(data[1].s, data[3].s, data[1].i, ci.fogNo);
this.drawWall(data[2].s, data[3].s, data[2].i, ci.fogNo);
} }
comes up without errors. Seeing no reaction, I assume this can be considered fixed.