back2dos / tinkerbell

MIT License
83 stars 8 forks source link

Using the traitish thing, came across this. #44

Closed 0b1kn00b closed 11 years ago

0b1kn00b commented 11 years ago
import tink.lang.Cls;
import haxe.rtti.CType;

class ClsPatternMatchingTest {
  public function new(){}
  public function test(u){
    var a = new ImplUsingPatternMatchingThing();
    return u;
  }
}
interface UsingPatternMatchingThing implements Cls{
  //ok
  public function apply(v:WithParams):Void{
    switch (v){
      case Without    :
      case With(a,b)  :
      trace(a);
      trace(b);
    }
  }
  //not ok
  public function applyC(v:CType):Void{
    switch (v){
      case CUnknown:
      case CEnum( name , params ) :
      default                     :
    }
  }
}
class ImplUsingPatternMatchingThing implements UsingPatternMatchingThing{
  public function new(){}
}
//needs to go in separate file
enum WithParams{
  Without;
  With(a:String,b:List<Int>);
}

produces

C:\world\stack\prj\tinkerbell\src/tink/lang/macros/loops/LoopSugar.hx:451: characters 11-17 : Invalid field access : index
C:\world\stack\prj\tinkerbell\src/tink/lang/macros/Syntax.hx:25: characters 7-14 : Called from
C:\world\stack\prj\tinkerbell\src/tink/lang/macros/Syntax.hx:44: characters 48-58 : Called from
C:\world\stack\prj\tinkerbell\src/tink/macro/tools/ExprTools.hx:444: characters 12-15 : Called from
C:\world\stack\prj\tinkerbell\src/tink/lang/macros/Syntax.hx:44: characters 48-79 : Called from
C:\world\stack\prj\tinkerbell\src/tink/macro/tools/ExprTools.hx:224: characters 21-35 : Called from
C:\world\stack\prj\tinkerbell\src/tink/macro/tools/ExprTools.hx:221: characters 10-53 : Called from
C:\world\stack\prj\tinkerbell\src/tink/macro/tools/ExprTools.hx:302: characters 28-36 : Called from
C:\world\stack\prj\tinkerbell\src/tink/macro/tools/ExprTools.hx:356: characters 12-31 : Called from
C:\world\stack\prj\tinkerbell\src/tink/macro/tools/ExprTools.hx:236: characters 30-64 : Called from
C:\world\stack\prj\tinkerbell\src/tink/lang/macros/Syntax.hx:44: characters 9-86 : Called from
C:\world\stack\prj\tinkerbell\src/tink/lang/macros/Syntax.hx:41: characters 9-21 : Called from
C:\world\stack\prj\tinkerbell\src/tink/lang/macros/Syntax.hx:36: characters 79-95 : Called from
C:\world\stack\prj\tinkerbell\src/tink/macro/tools/Bouncer.hx:29: characters 5-24 : Called from
C:\world\stack\prj\tinkerbell\src/tink/macro/tools/Bouncer.hx:47: characters 27-49 : Called from
src/test/haxe/ClsPatternMatchingTest.hx:22: lines 22-28 : Called from

very recent svn, compiled with -D haxe3

back2dos commented 11 years ago

Kind of works now. Please beware that currently you need to either fully qualify types in the partial implementation or import them in the implementor. Will see what to do about this.

0b1kn00b commented 11 years ago

did you push to haxe2? I'm getting a 'has no field' error on lazyComplex. (updated tink master, cleared compiler cache)

C:\world\stack\prj\tinkerbell\src/tink/macro/tools/ExprTools.hx:449: lines 449-451 : Void -> haxe.macro.Type has no field lazyComplex
back2dos commented 11 years ago

Ooops, sorry! ExprTools.lazyType wasn't really supposed to be in that changeset. Anyway, now it really should work ;)

0b1kn00b commented 11 years ago

sorry,

 C:\world\stack\prj\tinkerbell\src/tink/macro/tools/TypeTools.hx:92: characters 13-21 : haxe.macro.Function has no field asExpr

and that's

 var f = (macro null).func(fArgs, false); 
 f.expr = EReturn(member.call(f.getArgIdents(), e.pos)).at(e.pos);
 f.asExpr(e.pos).typeof().sure();
back2dos commented 11 years ago

I definitely need to review my approach to version control ... Please check again.

0b1kn00b commented 11 years ago

legend thanks.

0b1kn00b commented 11 years ago

will a module import import the classes? got it, thanks.