1) Quibble: your test is called 'shadowedArguments', which propagates
the myth that a var declaration 'shadows' a parameter declaration. In
Javascript a var declaration does not shadow a parameter declaration
(and neither do multiple var declarations shadow each other). Maybe a
better term is 'varScope'? You are really testing that the scope of a
var declaration is the body of the function, not local to a block.
[You'll be amused to know that JS2 introduces `let` declarations,
which have block scope, more like most other languages. For most
people, replacing `var` with `let` will be exactly what they want...]
Oh, and Javascript-speak for `varargs` is `rest args`. :)
2) More importantly: I don't think you want the hard-coded `with
(this)` in your closure. I think that will cause the following test
to fail:
var foo = {a: 3, test: function (a, ...rest) { return a;}};
foo.test(42) => ?
Should yield 42, but with(this) will cause it to yield 3 instead.
Otherwise, approved.
On 2009-02-17, at 17:30EST, Donald Anderson wrote:
Change 20090217-dda-N by [email protected] on 2009-02-17 17:09:17 EST
in /Users/dda/laszlo/src/svn/openlaszlo/trunk-g
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: Use apply() rather than call() in catcherrors implementation.
New Features:
Bugs Fixed: [LPP-7722] SWF9: method having argument and variable
with same name behave differently with catcherrors=true
Technical Reviewer: ptw (pending)
QA Reviewer: (pending)
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
** To be applied also to 4.2.0.2?
Changed catcherrors implementation to use apply() rather than
call() so that arguments appear the same
within the closure as in the original code. The one gotcha is
that the magic 'arguments' variable
is not available when there is a variable argument declaration
(...rest) present. When there is a single
argument (e.g. function foo(...rest)) the variable name (e.g.
rest) can be used in place of arguments. When there
are additional fixed arguments (e.g. function foo(a, b, ...rest))
the actual argument list array must be
assembled from the args (e.g. [a,b].concat(rest))
Added a compiler test to check this.
Tests:
Tried the test from the Jira.
Smoke test all platforms, including SWF9 using catcherrors.
Confirmed that new test is working by trying SWF9 with
catcherrors on a fresh tree with just the test changed.
{SWF9(with catcherrors=true),SWF8,dhtml} x {weather,lzpix}
Files:
M test/smoke/compiler.lzl
M WEB-INF/lps/server/src/org/openlaszlo/sc/
JavascriptGenerator.java
M WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/
ASTIdentifier.java
Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20090217-dda-N.tar
--
Don Anderson
Java/C/C++, Berkeley DB, systems consultant
voice: 617-306-2057
email: [email protected]
www: http://www.ddanderson.com