jsx / JSX

JSX - a faster, safer, easier JavaScript
http://jsx.github.io/
MIT License
1.46k stars 102 forks source link

default parameter with other param #326

Closed tuchida closed 10 years ago

tuchida commented 10 years ago

This code fails to compile.

class _Main {
    static function fn(a : number, b : number = a * 2) : number {
        return a + b;
    }

    static function main(args : string[]) : void {
        log _Main.fn(5);
    }
}
ERROR!
[input:2:48] could not find definition for template class: 'a'
    static function fn(a : number, b : number = a * 2) : number {
                                                ^
[input:2:48] no class definition or variable for 'a'
    static function fn(a : number, b : number = a * 2) : number {
                                                ^

In ECMAScript6 of Firefox, allow default parameters to be initialized with other parameter value. How do you feel about that?

kazuho commented 10 years ago

Thank you for the pull request. The feature will be included in the upcoming release.