Browse Source

[matcher] fix handling of CFields (closes #3680)

Simon Krajewski 10 years ago
parent
commit
55c52cfc69
2 changed files with 26 additions and 4 deletions
  1. 2 4
      matcher.ml
  2. 24 0
      tests/unit/src/unit/issues/Issue3680.hx

+ 2 - 4
matcher.ml

@@ -827,9 +827,9 @@ let rec all_ctors mctx t =
 		) en.e_constrs;
 		h,RunTimeFinite
 	| TAnon a ->
-		h,Infinite
+		h,CompileTimeFinite
 	| TInst(_,_) ->
-		h,Infinite
+		h,CompileTimeFinite
 	| _ ->
 		h,Infinite
 
@@ -932,8 +932,6 @@ let rec compile mctx stl pmat toplevel =
 			) sigma in
 			let def = default mctx pmat in
 			let dt = match def,cases with
-			| _ when List.exists (fun (c,_) -> match c.c_def with CFields _ -> true | _ -> false) cases ->
-				switch st_head cases
 			| _ when inf = RunTimeFinite && PMap.is_empty !all ->
 				switch st_head cases
 			| [],_ when inf = CompileTimeFinite && PMap.is_empty !all ->

+ 24 - 0
tests/unit/src/unit/issues/Issue3680.hx

@@ -0,0 +1,24 @@
+package unit.issues;
+
+private class Node<T> {
+    public var cur:T;
+    public var next:Null<Node<T>>;
+    public function new(cur)
+    {
+        this.cur = cur;
+    }
+}
+
+class Issue3680 extends Test {
+	function test() {
+		var a = "";
+        switch (new Node(1))
+        {
+            case { cur: 1, next: ({ cur : 2 }) }:
+                a = "assert";
+            default:
+                a = 'correct';
+        }
+		eq("correct", a);
+	}
+}