소스 검색

[matcher] dodge capture var vs. abstract field regression

see #7728
Simon Krajewski 6 년 전
부모
커밋
50836fe225
2개의 변경된 파일33개의 추가작업 그리고 0개의 파일을 삭제
  1. 11 0
      src/typing/matcher.ml
  2. 22 0
      tests/unit/src/unit/issues/Issue7728.hx

+ 11 - 0
src/typing/matcher.ml

@@ -250,12 +250,23 @@ module Pattern = struct
 				try_typing (EConst (Ident s),p)
 			with
 			| Exit | Bad_pattern _ ->
+				let restore =
+					let old = ctx.on_error in
+					ctx.on_error <- (fun _ _ _ ->
+						raise Exit
+					);
+					(fun () ->
+						ctx.on_error <- old
+					)
+				in
 				begin try
 					let mt = module_type_of_type t in
 					let e_mt = TyperBase.type_module_type ctx mt None p in
 					let e = type_field_access ctx ~resume:true e_mt s in
+					restore();
 					check_expr e
 				with _ ->
+					restore();
 					if not (is_lower_ident s) && (match s.[0] with '`' | '_' -> false | _ -> true) then begin
 						display_error ctx "Capture variables must be lower-case" p;
 					end;

+ 22 - 0
tests/unit/src/unit/issues/Issue7728.hx

@@ -0,0 +1,22 @@
+package unit.issues;
+
+private enum E {
+	A(s:S);
+}
+
+private abstract S(String) {
+	public var value(get, never):String;
+	function get_value():String return this;
+}
+
+class Issue7728 extends unit.Test {
+	function test() {
+
+	}
+
+	static function doTest(e:E):Void {
+		switch(e) {
+			case A(value):
+		}
+	}
+}