jsx / JSX

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

JSX minify issue #301

Closed shibukawa closed 10 years ago

shibukawa commented 10 years ago

In some case, minefield function name overwrite existing export function name.

import "console.jsx";

class A {
    __export__ function a() : void {
        console.log('a');
    }

    __export__ function _() : void {
        console.log('b');
    }
}

class _Main {
    static function main(argv: string[]) : void {
        var a = new A();
        a.a();
    }
}
$ jsx --version
0.9.78 (2014-02-20 16:35:31 +0900; da141e9a5ca211f770bca3f618109d2c443a1b72)
$ jsx --run test.jsx
a
$ jsx --minify --run test.jsx
b
Constellation commented 10 years ago

@kazuho Is this esmangle issue? If so, feel free to file it to esmangle issues.

shibukawa commented 10 years ago

@Constellation I don't think so. JSX has a minified name generator class (https://github.com/jsx/JSX/blob/master/src/jsemitter.jsx#L502). This class should detect name conflict.

kazuho commented 10 years ago

@shibukawa @Constellation Thank you for reporting the bug / looking into the issue.

The bug causing the issue is within the JSX compiler - the following conversion table is generated and used for converting property names; it is evident that the __export__ attribute is not handled correctly in this case.

 a$ => _
 _$ => A