Browse Source

[matcher] apply Simn's fix (closes #5392)

Dan Korostelev 9 years ago
parent
commit
5dfbb4822c
2 changed files with 17 additions and 1 deletions
  1. 1 1
      src/typing/matcher.ml
  2. 16 0
      tests/unit/src/unit/issues/Issue5392.hx

+ 1 - 1
src/typing/matcher.ml

@@ -228,7 +228,7 @@ module Pattern = struct
 		let handle_ident s p =
 			let save =
 				let old = ctx.locals in
-				ctx.locals <- PMap.empty;
+				ctx.locals <- (try PMap.add "this" (PMap.find "this" old) PMap.empty with Not_found -> PMap.empty);
 				(fun () ->
 					ctx.locals <- old;
 				)

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

@@ -0,0 +1,16 @@
+package unit.issues;
+
+private abstract A(Int) from Int {
+    public function size() {
+        return switch (this) {
+            case size: size;
+        }
+    }
+}
+
+class Issue5392 extends unit.Test {
+	function test() {
+        var a = (10 : A);
+        eq(10, a.size());
+	}
+}