2
0
Эх сурвалжийг харах

[matcher] embrace infinity

I have no idea why these were considered to be compile-time-finite because that seems dead wrong. There's a good chance that this breaks everyone's code, but that's a necessity.

closes #8277
Simon Krajewski 6 жил өмнө
parent
commit
717c28273c

+ 2 - 2
src/typing/matcher.ml

@@ -1319,9 +1319,9 @@ module TexprConverter = struct
 				PMap.iter (fun _ ef -> add (ConEnum(en,ef),null_pos)) en.e_constrs;
 				SKEnum,RunTimeFinite
 			| TAnon _ ->
-				SKValue,CompileTimeFinite
+				SKValue,Infinite
 			| TInst(_,_) ->
-				SKValue,CompileTimeFinite
+				SKValue,Infinite
 			| _ ->
 				SKValue,Infinite
 		in

+ 22 - 0
tests/misc/projects/Issue8277/Main1.hx

@@ -0,0 +1,22 @@
+class Main {
+	static final Up = new Point(0, -1);
+	static final Down = new Point(0, 1);
+
+	static function main() {}
+
+	function opposite(direction:Point):Point {
+		return switch (direction) {
+			case Up: Down;
+		}
+	}
+}
+
+class Point {
+	public final x:Int;
+	public final y:Int;
+
+	public function new(x, y) {
+		this.x = x;
+		this.y = y;
+	}
+}

+ 17 - 0
tests/misc/projects/Issue8277/Main2.hx

@@ -0,0 +1,17 @@
+typedef C = { foo: Int }
+
+enum E {
+	A(v:C);
+}
+
+class Main {
+	static final ident:C = null;
+
+	static function f(e:E):Int {
+		return switch e {
+			case A(ident): 0;
+		}
+	}
+
+	static function main() {}
+}

+ 1 - 0
tests/misc/projects/Issue8277/compile1-fail.hxml

@@ -0,0 +1 @@
+-main Main1

+ 1 - 0
tests/misc/projects/Issue8277/compile1-fail.hxml.stderr

@@ -0,0 +1 @@
+Main1.hx:8: characters 18-27 : Unmatched patterns: _

+ 1 - 0
tests/misc/projects/Issue8277/compile2-fail.hxml

@@ -0,0 +1 @@
+-main Main2

+ 1 - 0
tests/misc/projects/Issue8277/compile2-fail.hxml.stderr

@@ -0,0 +1 @@
+Main2.hx:12: characters 11-16 : Unmatched patterns: A(_)