History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: LPP-4365
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: -- --
Assignee: Unassigned
Reporter: Steve Baker
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
OpenLaszlo

Adding prototype functions to builtin objects a bit broken

Created: 25/Jul/07 07:48 PM   Updated: 21/Aug/07 01:55 PM
Component/s: Compiler - JavaScript
Affects Version/s: 4.0.2
Fix Version/s: 4.0.5WaffleCone

Time Tracking:
Not Specified

File Attachments: 1. File testPrototype.lzx (0.9 kb)
2. File testPrototype.lzx (0.8 kb)

Environment: Ubuntu Feisty Fawn, Firefox 2.0.0.5, Flash plugin 9.0 r48

Severity: Minor
Runtime: N/A
Fix in hand: False


 Description  « Hide
Calling a prototype function straight after an object constructor doesn't work.

See the attached unit test, the following:
assertEquals(new Date().testProto(), 'prototype function works');

fails when it should work the same as:
var d = new Date();
assertEquals(d.testProto(), 'prototype function works');

which passes.

Debug log displays:
WARNING: testPrototype.lzx:29: reference to undefined property 'testProto'
ERROR: Compiler.substitute:-1: undefined object does not have a property 'make'
ERROR: Equals: expected «undefined» got 'prototype function works'

Unit test result displays:
Tests: 3 Failures: 1 Errors: 2
TestFailure: testNoVars failed: Equals: expected «undefined» got 'prototype function works'
TestError: testNoVars failed: undefined object does not have a property 'make'
TestError: testNoVars failed: reference to undefined property 'testProto'

The workaround is to assign the object to a var before using it, but this can really be used in a constraint.

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Steve Baker - 25/Jul/07 07:49 PM
Test case with 3 tests. Test 3 fails.

P T Withington - 26/Jul/07 05:33 AM
I think this is a bug in the parser's precedence implementation. Does:

(new Date()).testProto()

work?

Steve Baker - 26/Jul/07 02:20 PM
(new Date()).testProto() works correctly.

Unit test has been updated to include this case.

Steve Baker - 26/Jul/07 02:32 PM
The comment for testBrackets should be:
// this passes

P T Withington - 17/Aug/07 12:50 PM
Duplicate of LPP-1605

Mamye Kratt - 21/Aug/07 01:55 PM
(wafflecone branch local build r6169)
Ran 2 testfiles in bug successfully in swf, swf8 and dhtml.