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

only match against fields that we can actually access (closes #6133)

Simon Krajewski 8 жил өмнө
parent
commit
05927223f8

+ 4 - 1
src/typing/matcher.ml

@@ -360,7 +360,10 @@ module Pattern = struct
 						PMap.fold (fun cf acc -> (cf,cf.cf_type) :: acc) an.a_fields []
 					| TInst(c,tl) ->
 						let rec loop fields c tl =
-							let fields = List.fold_left (fun acc cf -> (cf,apply_params c.cl_params tl cf.cf_type) :: acc) fields c.cl_ordered_fields in
+							let fields = List.fold_left (fun acc cf ->
+								if Typer.can_access ctx c cf false then (cf,apply_params c.cl_params tl cf.cf_type) :: acc
+								else acc
+							) fields c.cl_ordered_fields in
 							match c.cl_super with
 								| None -> fields
 								| Some (csup,tlsup) -> loop fields csup (List.map (apply_params c.cl_params tl) tlsup)

+ 16 - 0
tests/unit/src/unit/issues/Issue6133.hx

@@ -0,0 +1,16 @@
+package unit.issues;
+
+private class Foo {
+	private var __a:Int;
+	public var b:Int;
+	public function new() {}
+}
+
+class Issue6133 extends unit.Test {
+	function test() {
+		var foo = new Foo();
+		switch foo {
+			case { b: 5 }:
+		}
+	}
+}