waneck / testrepo

0 stars 0 forks source link

Issue 1430 - Context.typeof is not catchable when display defined - haxe #1430

Open waneck opened 11 years ago

waneck commented 11 years ago

[Google Issue #1430 : http://code.google.com/haxe/issues/detail?id=1430] by heinz.ho...@googlemail.com, at 2013-01-28T02:18:49.000Z haxe.macro.Context.typeof is not catchable during "display" completion. Please test the following example. If Context.typeof throws an error, the catch block is never entered.

class Macros {

macro public static function test (e:haxe.macro.Expr):haxe.macro.Expr {

    return try {
        haxe.macro.Context.typeof(e); 
        macro "foo";

}

    catch (e1:Dynamic) {
        macro [1];

} } }

if !macro

class Test {

public static function main () 
{

    Macros.test(haxe.crypto.Adler32).| // Expected String Completion

    // haxe.crypto is a package, so Context.typeof should fail and the catch block should be entered
    Macros.test(haxe.crypto).| // no completion here

}

}

end

waneck commented 11 years ago

[comment from si...@haxe.org, published at 2013-01-30T09:35:42.000Z] I found the main culprit here: http://code.google.com/p/haxe/source/browse/trunk/typer.ml#1774

However, even after removing that completion is wrong in some cases: var x = Macros.test(haxe.crypto); $type(x); // Array x.| // charAt etc. That's with -D no-copt in place.

waneck commented 11 years ago

[comment from si...@haxe.org, published at 2013-02-02T14:47:46.000Z] line changed: http://code.google.com/p/haxe/source/browse/trunk/typer.ml#1767

waneck commented 11 years ago

[comment from si...@haxe.org, published at 2013-02-09T19:12:48.000Z]

waneck commented 11 years ago

[comment from si...@haxe.org, published at 2013-02-22T23:47:15.000Z]

waneck commented 11 years ago

[comment from si...@haxe.org, published at 2013-02-24T16:25:57.000Z] pull back to haxe 3

waneck commented 11 years ago

[comment from si...@haxe.org, published at 2013-02-24T16:47:50.000Z]

waneck commented 11 years ago

[comment from si...@haxe.org, published at 2013-02-24T16:50:17.000Z]

waneck commented 11 years ago

[comment from ncanna...@gmail.com, published at 2013-05-04T14:16:32.000Z] It seems to be even worse now : both cases display Unknown<0> completion. Simon if you can help localize the issue...

waneck commented 11 years ago

[comment from si...@haxe.org, published at 2013-05-04T20:40:50.000Z] https://code.google.com/p/haxe/source/browse/trunk/typer.ml#2113

if ctx.indisplay then raise (Parser.TypePath (List.map (fun (n,,_) -> n) (List.rev acc),None));

That seems to have a part in the problem, but comment 1 still applies ($type gives Array, but completion suggest String methods).

waneck commented 11 years ago

[comment from si...@haxe.org, published at 2013-05-24T12:04:04.000Z]