[Laszlo-dev] For Review: Change 20090108-dda-O Summary: Remove references to 'this' in static functions (revised)
Donald Anderson
dda at ddanderson.com
Fri Jan 9 19:52:09 PST 2009
I tried the new test case that you listed in the JIRA and it did not
do the right thing.
Turned out the catcherrors was effectively turned off in any case
where a function expression
(rather than a function definition) was used. I fixed this and the
test case now correctly
reports:
ERROR: ReferenceError: Error #1065
DEBUG: bar: 42
However smoketest fails (with catcherrors on) for SWF9. I get:
Tests: 880 Failures: 1 Errors: 1
TestFailure: «<IntentionalErrors>»/testUndefinedErrors failed:
Total number of expected errors: expected 1 got 0
TestError: «<IntentionalErrors>»/testUndefinedErrors failed: Wrong
error: expected «function» got 'testing: 1, 2, 3'
Haven't tracked this down yet.
On Jan 9, 2009, at 12:58 PM, P T Withington wrote:
> Reverse the two do clauses, then I don't see the bar output, which I
> would have thought I should have? (See my notes in Jira).
>
> If your revised change using the isjs2 flag fixes the original bug,
> lets review that, get it in and migrated to 4.2.0.1 and split off a
> new bug to make my additional test work.
>
> On 2009-01-09, at 12:39EST, Donald Anderson wrote:
>
>> Yes, it works in that it compiles and gives the result:
>>
>> DEBUG: bar: 42
>> ERROR @LPP-7514b.lzx#17: ReferenceError: Error #1065
>>
>> (tested with catcherrors set to true).
>>
>> How should we proceed?
>>
>> - Don
>>
>> On Jan 9, 2009, at 12:23 PM, P T Withington wrote:
>>
>>> There's still going to be some corner case though, that I am not
>>> sure we have thought out:
>>>
>>> When the tag compiler compiles an LZX class, _sometimes_ it has to
>>> write a method as a closure, in which case it outputs:
>>>
>>> var meth = function (...) { #pragma withThis ... }
>>>
>>> and in that case, it really wants a `with (this)` emitted in that
>>> function body (which means you need it in your try closure too).
>>>
>>> Does the current mechanism do the right thing? Here's a simple
>>> test case:
>>>
>>> <canvas debug="true">
>>> <class name="foo">
>>> <attribute name="bar" value="42" />
>>> <state applied="true">
>>> <method name="doit">
>>> Debug.debug("bar: %#w", bar);
>>> </method>
>>> <method name="dontit">
>>> Debug.debug("bar: %#w", bletch);
>>> </method>
>>> </state>
>>> <handler name="oninit">
>>> doit();
>>> // Should cause a caught error
>>> dontit();
>>> </handler>
>>> </class>
>>>
>>> <foo />
>>>
>>> </canvas>
>>>
>>> On 2009-01-09, at 11:48EST, Donald Anderson wrote:
>>>
>>>> Oh, right, that would have been a lot easier.
>>>> I'll make a new changeset.
>>>>
>>>> On Jan 9, 2009, at 11:02 AM, P T Withington wrote:
>>>>
>>>>> Shouldn't it be sufficient to simply use the same flag you use
>>>>> to ignore the withThis pragma for js2 to conditionalize emitting
>>>>> the `with (this)` in your try closure? (I think you use the
>>>>> `remaplocals()` predicate, but maybe that should be renamed
>>>>> `isjs2()`?
>>>>>
>>>>> On 2009-01-09, at 09:44EST, Donald Anderson wrote:
>>>>>
>>>>>> Change 20090108-dda-O by dda at lester.local on 2009-01-08
>>>>>> 06:25:08 EST
>>>>>> in /Users/dda/laszlo/src/svn/openlaszlo/trunk-c
>>>>>> for http://svn.openlaszlo.org/openlaszlo/trunk
>>>>>>
>>>>>> Summary: Remove references to 'this' in static functions
>>>>>> (revised)
>>>>>>
>>>>>> New Features:
>>>>>>
>>>>>> Bugs Fixed: LPP-7514 (Compilation error when setting
>>>>>> compiler.swf9.catcherrors=true in lps.properties)
>>>>>>
>>>>>> Technical Reviewer: ptw (pending)
>>>>>> QA Reviewer: (pending)
>>>>>> Doc Reviewer: (pending)
>>>>>>
>>>>>> Documentation:
>>>>>>
>>>>>> Release Notes:
>>>>>>
>>>>>> Details:
>>>>>> [This changeset revises an earlier one sent to review, fixing
>>>>>> an ugly workaround.
>>>>>> Everything indicated under Tests has been retested with this
>>>>>> revision.]
>>>>>>
>>>>>> The implementation of catchFunctionExceptions (catcherrors) was
>>>>>> blind to static functions,
>>>>>> 'this' cannot be used in static functions.
>>>>>>
>>>>>> To tell that a function is static, this changeset peeks up the
>>>>>> tree to the parent
>>>>>> of the function node, which should be a ASTModifiedDefinition
>>>>>> ('moddef'), and checks the static
>>>>>> flag there. A shortcut in copying part of the tree without the
>>>>>> moddef
>>>>>> needed to be fixed, to do that, a 'shallow copy' function was
>>>>>> added to the moddef class.
>>>>>>
>>>>>> An alternate way of detecting static-ness is to set a 'static'
>>>>>> property in the options.
>>>>>> I had tried in addressing LPP-5813 (not yet completed), and had
>>>>>> some trouble getting
>>>>>> it to work. It's not clear which one is cleaner, but the one
>>>>>> that works wins for me.
>>>>>>
>>>>>> This fix is slightly more encompassing than it needs to be, it
>>>>>> also disables any possibility
>>>>>> of applying the WITH_THIS directive within a static function.
>>>>>> This should always be
>>>>>> correct. Changing that to be narrower did not affect the SWF8
>>>>>> problem.
>>>>>>
>>>>>>
>>>>>> Tests:
>>>>>> (dhtml,swf8,swf9) x (lzpix,weather,smokecheck,hello) x (enable
>>>>>> catcherrors, disable catcherrors)
>>>>>>
>>>>>> Files:
>>>>>> M WEB-INF/lps/server/src/org/openlaszlo/sc/
>>>>>> JavascriptGenerator.java
>>>>>> M WEB-INF/lps/server/src/org/openlaszlo/sc/
>>>>>> CommonGenerator.java
>>>>>> M WEB-INF/lps/server/src/org/openlaszlo/sc/
>>>>>> CodeGenerator.java
>>>>>> M WEB-INF/lps/server/sc/src/org/openlaszlo/sc/parser/
>>>>>> ASTModifiedDefinition.java
>>>>>>
>>>>>> Changeset: http://svn.openlaszlo.org/openlaszlo/patches/20090108-dda-O.tar
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> Don Anderson
>>>>>> Java/C/C++, Berkeley DB, systems consultant
>>>>>>
>>>>>> voice: 617-306-2057
>>>>>> email: dda at ddanderson.com
>>>>>> www: http://www.ddanderson.com
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> Don Anderson
>>>> Java/C/C++, Berkeley DB, systems consultant
>>>>
>>>> voice: 617-306-2057
>>>> email: dda at ddanderson.com
>>>> www: http://www.ddanderson.com
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>> --
>>
>> Don Anderson
>> Java/C/C++, Berkeley DB, systems consultant
>>
>> voice: 617-306-2057
>> email: dda at ddanderson.com
>> www: http://www.ddanderson.com
>>
>>
>>
>>
>>
>
--
Don Anderson
Java/C/C++, Berkeley DB, systems consultant
voice: 617-306-2057
email: dda at ddanderson.com
www: http://www.ddanderson.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.openlaszlo.org/pipermail/laszlo-dev/attachments/20090109/202aed2d/attachment-0001.html
More information about the Laszlo-dev
mailing list