Skip to content

Commit

Permalink
instances are infinite sets (see HaxeFoundation#3031)
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed May 28, 2014
1 parent 5493c1a commit 2b8e73a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion matcher.ml
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ let rec all_ctors mctx t =
| TAnon a ->
h,true
| TInst(_,_) ->
h,false
h,true
| _ ->
h,true

Expand Down
34 changes: 34 additions & 0 deletions tests/unit/issues/Issue3031.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package unit.issues;

private class X {
public var s:String;
public function new(s:String) {
this.s = s;
}
}

class Issue3031 extends Test {
function testArty() {
var a = "";
switch (new StringBuf()) {
case null: a = "null";
case notNull: a = "not null";
}
eq("not null", a);
}

function testHeinz() {
function doSwitch(x1:Null<X>, x2:Null<X>) {
return switch [x1,x2] {
case [null,null]: "";
case [a,null]: a.s;
case [null,b]: b.s;
case [a,b]: a.s + b.s;
}
}
eq("", doSwitch(null, null));
eq("foo", doSwitch(new X("foo"), null));
eq("bar", doSwitch(null, new X("bar")));
eq("foobar", doSwitch(new X("foo"), new X("bar")));
}
}

0 comments on commit 2b8e73a

Please sign in to comment.