Last modified: 2014-03-08 01:02:22 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T64405, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 62405 - Documentation for inheritClass has broken example
Documentation for inheritClass has broken example
Status: RESOLVED FIXED
Product: OOjs
Classification: Unclassified
General (Other open bugs)
unspecified
All All
: Normal trivial
: ---
Assigned To: Krinkle
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-03-07 21:17 UTC by Tisza Gergő
Modified: 2014-03-08 01:02 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Tisza Gergő 2014-03-07 21:17:54 UTC
The docblock for inheritClass uses this code snippet as an example:

    function Thing() {}
    Thing.prototype.exists = function () {};

    function Person() {
        this.constructor.super.apply( this, arguments );
    }
    oo.inheritClass( Person, Thing );
    Person.static.defaultEyeCount = 2;
    Person.prototype.walk = function () {};

    function Jumper() {
         this.constructor.super.apply( this, arguments );
    }
    OO.inheritClass( Jumper, Person );
    Jumper.prototype.jump = function () {};

    Jumper.static.defaultEyeCount === 2;
    var x = new Jumper();

When actually executed, this will result in an infinite recursion since this.constructor.super does not change as the call progresses up the inheritance chain.
Comment 1 Krinkle 2014-03-07 21:25:13 UTC
Ah, of course. Though "super" allows avoiding harcoding of the parent's class name, it does require you to reference the "current" class name as it otherwise will indeed never resolve.

Proper syntax is:

> function Person() {
>     Person.super.apply( this, arguments );
> }
Comment 2 Gerrit Notification Bot 2014-03-07 21:34:53 UTC
Change 117479 had a related patch set uploaded by Krinkle:
inheritClass: Use Class.super instead of this.constructor.super

https://gerrit.wikimedia.org/r/117479
Comment 3 Gerrit Notification Bot 2014-03-08 00:47:50 UTC
Change 117479 merged by jenkins-bot:
inheritClass: Use Class.super instead of this.constructor.super

https://gerrit.wikimedia.org/r/117479
Comment 4 James Forrester 2014-03-08 01:02:22 UTC
Thanks for the spot!

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links