back2dos / tinkerbell

MIT License
83 stars 8 forks source link

Strange completion issue when using tink_macro #54

Open jdonaldson opened 11 years ago

jdonaldson commented 11 years ago

I have the following (greatly simplfied) class and method, where I want to retrieve completions:

import MacroClass;

class Test {
    static function main() {
        var m = new MacroClass(); // delete either this line
        var x = 'hi'; // or this one, and it will work. 
        MacroClass.func(4). // trigger completion here.
    }
}

When I trigger the completion after MacroClass.func(m).|, I get back a single "unknown" type value from the compiler.

Strangely enough, if I delete the "x" variable declaration it works. Or, if I delete the constructor variable declaration, it works. Also, if I delete the import of TypeTools, it will work. Here's the MacroClass class from above. It just returns a macro'd string, and I'd expect to see relevant completions for string methods as completion candidates:

#if macro
import haxe.macro.Expr;
using tink.macro.tools.TypeTools; // commenting this out also makes completion work in Test.hx
#end

class MacroClass {
    public function new(){}
    macro public static function func(arg:Expr):Expr{
        return macro 'hi';
    }
}

Also, here's a simple build file that will pull this together:

-main Test
-x out 
-lib tink_macro
-lib tink_core

I'm on haxe 3 fwiw.

back2dos commented 11 years ago

Ok, this is really weird but I cannot really track down the cause of it. I've tried commenting out everything in TypeTools to find out that even such harmless functions as reduce make it fail. However the problem does disappear when using the compiler server.

jdonaldson commented 11 years ago

Thanks for looking into it. I had a hard time even coming up with a minimal example. Unfortunately, this problem really affects the usability of Promise. The argument types are altered via a macro, and a --display completion makes the new types clear. I was hoping that you would see some sort of clue :/

back2dos commented 11 years ago

Yeah, sorry, I'll try to make a minimal example for Simn. But in any case it's nothing I think I can solve, so you'll have to not use tink_macro or use the compilation server until the next Haxe version. Which hopefully is coming soon.

jdonaldson commented 11 years ago

Thanks for passing this along. TInk is becoming "bread and butter" for a lot of my macro work. Great stuff.

jdonaldson commented 10 years ago

FWIW I ended up finding another way to do this without TypeTools. But, I'll keep tabs on this for the future.