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

[matcher] fixed matching with deprecated inline vars (closes #9204)

Aleksandr Kuzmenko 5 жил өмнө
parent
commit
7bf95961e6

+ 2 - 0
src/typing/matcher.ml

@@ -234,6 +234,8 @@ module Pattern = struct
 					raise (Bad_pattern "Only inline or read-only (default, never) fields can be used as a pattern")
 				| TTypeExpr mt ->
 					PatConstructor(con_type_expr mt e.epos,[])
+				| TMeta((Meta.Deprecated,_,_), e) ->
+					loop e
 				| _ ->
 					raise Exit
 			in

+ 18 - 0
tests/unit/src/unit/issues/Issue9204.hx

@@ -0,0 +1,18 @@
+package unit.issues;
+
+class Issue9204 extends unit.Test {
+	@:deprecated
+	static inline final DEPRECATED = 123;
+
+	function test() {
+		eq(1, switchWithDeprecated(123));
+		eq(2, switchWithDeprecated(321));
+	}
+
+	static public function switchWithDeprecated(x:Int) {
+		return switch x {
+			case DEPRECATED: 1;
+			case _: 2;
+		}
+	}
+}