浏览代码

[matcher] don't bother if there are no cases

closes #8506
Simon Krajewski 6 年之前
父节点
当前提交
d753f9976e
共有 2 个文件被更改,包括 17 次插入0 次删除
  1. 6 0
      src/typing/matcher.ml
  2. 11 0
      tests/unit/src/unit/issues/Issue8506.hx

+ 6 - 0
src/typing/matcher.ml

@@ -1610,4 +1610,10 @@ module Match = struct
 			print_endline "TEXPR END";
 			print_endline "TEXPR END";
 		end;
 		end;
 		{e with epos = p}
 		{e with epos = p}
+
+	let match_expr ctx e cases def with_type postfix_match p = match cases,def with
+		| [],None ->
+			type_expr ctx e WithType.value
+		| _ ->
+			match_expr ctx e cases def with_type postfix_match p
 end
 end

+ 11 - 0
tests/unit/src/unit/issues/Issue8506.hx

@@ -0,0 +1,11 @@
+package unit.issues;
+
+import utest.Assert;
+
+class Issue8506 extends unit.Test {
+	static var s = "hi";
+	function test() {
+		switch s {}
+		Assert.pass();
+	}
+}