netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

Invalid error detection in Javascript syntax

Open grelf-net opened this issue 1 year ago • 4 comments
trafficstars

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

Screenshot 2024-04-11 155614

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

grelf-net avatar Apr 11 '24 15:04 grelf-net

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.

grelf-net avatar Apr 11 '24 15:04 grelf-net

Lets reopen - I'll see what to do about this.

matthiasblaesing avatar Apr 11 '24 15:04 matthiasblaesing

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.

grelf-net avatar Apr 12 '24 12:04 grelf-net

This is not reproducible in current build:

image

Please check with the nightly build available here:

https://ci-builds.apache.org/job/Netbeans/job/netbeans-linux/lastSuccessfulBuild/artifact/nbbuild/

Please note:

  1. The ZIP in the referenced folder holds the ZIP Distribution of NetBeans. Expand it and you find a netbeans folder with the full installation.
  2. You need at least JDK 17 to run NetBeans 22 (on my main machine and @work I'm on Amazon Corretto 21)
  3. If the JDK can't be automatically found, uncomment the line with the variable netbeans_jdkhome in the file netbeans/etc/netbeans.conf and set the a path to the JDK there. On my windows test system for example it currently reads (with Amazon Corretto 17): image

matthiasblaesing avatar Apr 18 '24 19:04 matthiasblaesing

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.

matthiasblaesing avatar Oct 27 '24 14:10 matthiasblaesing