tinkerbell icon indicating copy to clipboard operation
tinkerbell copied to clipboard

Strange completion issue when using tink_macro

Open jdonaldson opened this issue 12 years ago • 5 comments

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.

jdonaldson avatar Jul 07 '13 19:07 jdonaldson

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.

back2dos avatar Jul 08 '13 07:07 back2dos

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 :/

jdonaldson avatar Jul 08 '13 18:07 jdonaldson

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.

back2dos avatar Jul 09 '13 09:07 back2dos

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

jdonaldson avatar Jul 29 '13 05:07 jdonaldson

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

jdonaldson avatar Sep 30 '13 21:09 jdonaldson