Page 1 of 1

problems pane

PostPosted: Thu Aug 26, 2010 1:21 am
by mboegem
I was wondering: in the problems pane you have the possibility to show variables which are declared twice.

Is there a possibility to find/report all undeclared vars?
In our environment we don't use vars that arn't declared.

Re: problems pane

PostPosted: Thu Aug 26, 2010 9:46 am
by pbakker
Unfortunately currently not: The warning reporting is based on the JavaScript Strict mode implementation of the JavaScript engine and assigning undeclared variables is not considered wrong (unfortunatly).

The latest version of JavaScript (EcmaScript), version 5 (ES5) has formalized Strict mode and it contains 2 items to this respect:
- When the JavaScript code is running in strict mode, it's not allowed to create variables without using the var keyword
- You can "seal" objects after declaration, which means that trying to set a property that doesn't exist on the object will thrown an error, instead of adding the property.

Now, the question is: when can we have it? Dunno, unfortunately, all makers of JavaScript engines (ie most browser vendors and Mozilla Rhino (which we use)) are still working on implementing all of this. As soon as Rhino has implemented it, we can start considering upgrading the Rhino engine version used in Servoy.

In other words: it'll not happen overnight unfortunalty.

Paul

Re: problems pane

PostPosted: Thu Aug 26, 2010 9:54 am
by mboegem
thnkx Paul for this clarification.

Re: problems pane

PostPosted: Thu Aug 26, 2010 3:08 pm
by jcompagner
one good thing is.. that in servoy 6 we will use our own parser and problem generator for the js files in the developer..

So even if Rhino doesnt support this, this will not say that we cant generate warnings or errors for it..

So you could make a case for it to see if we can make optional additional checks and how to report them (warning or error)