Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 299211

Summary: [validation] Valid JavaScript code flagged as error (regexp, infinity, non-breaking space)
Product: [WebTools] JSDT Reporter: Mikael Hakman <mhakman>
Component: GeneralAssignee: wst.javascript <wst.javascript-inbox>
Status: RESOLVED FIXED QA Contact: Nitin Dahyabhai <thatnitind>
Severity: major    
Priority: P3 CC: cmjaun, crimaniak, jacek.pospychala, mhakman, Olivier_Thomann, paul.beusterien, Viktor.Pracht
Version: 3.1.1   
Target Milestone: Future   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Snippet to reproduce issue 1 none

Description Mikael Hakman CLA 2010-01-10 06:35:38 EST
Build Identifier: Eclipse 20090920-1017 ATF 0.3.0

1. Using Unicode A0 character (non-breaking space) in UTF-8 encoded JavaScript files gives "Invalid Character" error. Note this is not within string litterals but in plain code.

2. The following code gives "Syntax Error on token ',',.expected":
   while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) {

3. The following code gives "String litteral is not properly closed by double quote":
   NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,

4. The following code gives "Syntax Error on token "infinity":
   var infinity = 1 / 0;


Reproducible: Always

Steps to Reproduce:
1. Download the qooxdoo SDK from http://qooxdoo.org/download (http://downloads.sourceforge.net/qooxdoo/qooxdoo-1.0-sdk.zip)
2. Unzip the file.
3. Create new JavaScript project in Eclipse.
4. Right-click on the project, set "Properties/Resource/Text file encoding" to UTF-8.
5. Import the whole Qooxdoo SDK into this project.
6. Rebuild.
Comment 1 Jacek Pospychala CLA 2010-01-11 02:39:08 EST
hi Mikael,
thanks for the report. I'll reassign bug to JSDT because that's the project which does all the JavaScript files syntax parsing and analysis.
Comment 2 Alexey Kulentsov CLA 2010-10-21 07:21:48 EDT
Here is more then one error. First of all it's code from jquery so you can test it on any project with jquery.

Case 2 - parser doesn't recognize ',' operator
Case 3 - parser doesn't recognize RegExp constant syntax /.../

Case 1 - I don't think using typographics symbols in program code is good idea.
Comment 3 Chris Jaun CLA 2011-06-28 15:07:38 EDT
Problems 2, 3, and 4 below have been fixed as of 3.2.4.

I wasn't sure how to reproduce problem 1. If that is still an issue, please re-open with a specific code snippet to reproduce.
Comment 4 Viktor Pracht CLA 2013-03-01 08:04:35 EST
I can't reopen the bug myself, but to reproduce issue 1, just replace a normal space by a non-breaking space. Here are some for copy-pasting:

varĀ    x;

It's an issue because NBSP is explicitly defined in the ECMAScript spec as a valid whitespace character.
Comment 5 Viktor Pracht CLA 2013-03-01 08:11:06 EST
Created attachment 227798 [details]
Snippet to reproduce issue 1

Since Bugzilla ate the NBSPs, here's an attachment, which hopefully preserves them.