Explorar o código

[matcher] fix exhaustive oopsie

closes #11171
Simon Krajewski %!s(int64=2) %!d(string=hai) anos
pai
achega
70a38a76e7

+ 1 - 1
src/typing/matcher/texprConverter.ml

@@ -292,7 +292,7 @@ let to_texpr ctx t_switch with_type dt =
 						| [{case_patterns = [{eexpr = TConst (TBool false)}];case_expr = e2};{case_patterns = [{eexpr = TConst (TBool true)}];case_expr = e1}],None,_ ->
 						| [{case_patterns = [{eexpr = TConst (TBool false)}];case_expr = e2};{case_patterns = [{eexpr = TConst (TBool true)}];case_expr = e1}],None,_ ->
 							mk (TIf(e_subject,e1,Some e2)) t_switch dt.dt_pos
 							mk (TIf(e_subject,e1,Some e2)) t_switch dt.dt_pos
 						| _ ->
 						| _ ->
-							let is_exhaustive = match finiteness with
+							let is_exhaustive = e_default <> None || match finiteness with
 								| RunTimeFinite | CompileTimeFinite when e_default = None ->
 								| RunTimeFinite | CompileTimeFinite when e_default = None ->
 									true
 									true
 								| _ ->
 								| _ ->

+ 24 - 0
tests/unit/src/unit/issues/Issue11171.hx

@@ -0,0 +1,24 @@
+package unit.issues;
+
+inline function getBlendFunc(value:Int):Context3DBlendFactor {
+	switch (value) {
+		case 0:
+			return Context3DBlendFactor.ZERO;
+		case 1:
+			return Context3DBlendFactor.ONE;
+		default:
+			throw "unsupported blending function";
+	}
+}
+
+class Issue11171 extends Test {
+	function test() {
+		getBlendFunc(0);
+		utest.Assert.pass();
+	}
+}
+
+private enum abstract Context3DBlendFactor(Int) {
+	public var ONE = 2;
+	public var ZERO = 9;
+}