HaxeCheckstyle / haxeparser

A Haxe parser for Haxe
61 stars 23 forks source link

Can't distuingish escaped and interpolation dollar signs #36

Closed Gama11 closed 7 years ago

Gama11 commented 8 years ago
class Main {
    public static function main() {
        trace(new haxeparser.HaxeParser(byte.ByteData.ofBytes(sys.io.File.getBytes("File.hx")), "").parse());
    }
}

File.hx (escaped $):

class C {
    var j = "";
    var i = '$$j';
}

File.hx (interpolation $):

class C {
    var j = "";
    var i = '$j';
}

Both of these result in EConst(CString($j)) as the expression for i, which means you can't tell them apart. In haxeparser 3.2.0, the escaped $ would actually show as two dollar signs in the expression: EConst(CString($$j))

This causes some of the failures in https://github.com/HaxeCheckstyle/haxe-checkstyle/issues/262.

Gama11 commented 8 years ago

Related issue: https://github.com/HaxeFoundation/haxe/issues/1852

Simn commented 7 years ago

I'll go ahead and close this because it's consistent with how Haxe lexes it. I'm not saying that approach isn't shit, but for now I want to keep haxeparser as close to Haxe as possible.