Closed Bug 511778 Opened 10 years ago Closed 10 years ago

class Object { static function init () ... } is too visible

Categories

(Tamarin Graveyard :: Virtual Machine, defect)

defect
Not set

Tracking

(Not tracked)

VERIFIED FIXED
Future

People

(Reporter: jodyer, Assigned: lhansen)

References

Details

(Whiteboard: Has patch)

Attachments

(1 file)

it is visible to code in all classes defined in the unnamed package, and so either shadows outer bindings named 'init' or masks mis-spellings of 'init'.

An obvious solution is to put 'init' into a hidden namespace, but there are probably others that should be considered (like restructuring the code to avoid the need for a static method for initialization). 

Jd
Target Milestone: --- → Future
This has a bit of impact on Flash Builder users -- whenever they bring up code hints for "this" for any class, they will see init() as one of the possible completions, even if the class doesn't have an init() function; this is potentially a little confusing.
Krzysztof was bitten by this on Friday.  He had some code that looked something like this (this is from memory):

// init.as
package {
    public namespace init = "http://example.com";
}

// MyClass.as
package {
    public class MyClass {
        use namespace init;
        ....
        public function foo():void {
            foo.init::bar = 3;
        }
    }
}

He kept getting strange compile-time error messages; when I took a look, I remembered this bug, and told him to rename his namespace "init" to something else, and that fixed it.
Versioning will fix this.
Assignee: nobody → lhansen
Depends on: 559994
Simplest test case - this should print 'undefined':

package {
  print(Object.init);
}
Attached patch PatchSplinter Review
Not for review yet, but once bug #559994 lands this will be roughly the right fix for the present bug.
Status: NEW → ASSIGNED
Whiteboard: Has patch
Attachment #440031 - Flags: review?(jodyer)
Attachment #440031 - Flags: review?(jodyer) → review+
tamarin-redux changeset:   4567:702d6ecfdb7b
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
confirmed fixed
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.