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

[eval,hl] fix catching value exceptions

Closes #11321
Rudy Ges 1 жил өмнө
parent
commit
269fef4788

+ 1 - 1
src/filters/exceptions.ml

@@ -484,7 +484,7 @@ let catch_native ctx catches t p =
 			| [], None ->
 			| [], None ->
 				catches_to_ifs ctx catches t p
 				catches_to_ifs ctx catches t p
 			| [], Some catch ->
 			| [], Some catch ->
-				catches_to_ifs ctx [catch] t p
+				catches_to_ifs ctx (catch :: catches) t p
 			| _ ->
 			| _ ->
 				catches_as_value_exception ctx handle_as_value_exception None t p
 				catches_as_value_exception ctx handle_as_value_exception None t p
 				:: catches_to_ifs ctx catches t p
 				:: catches_to_ifs ctx catches t p

+ 8 - 0
tests/unit/src/unit/TestExceptions.hx

@@ -162,6 +162,14 @@ class TestExceptions extends Test {
 		} catch(e:String) {
 		} catch(e:String) {
 			eq('string', e);
 			eq('string', e);
 		}
 		}
+
+		try {
+			throw new CustomHaxeException('Terrible error');
+		} catch(e:haxe.ValueException) {
+			throw 'should not happen';
+		} catch(e) {
+			Assert.pass();
+		}
 	}
 	}
 
 
 	public function testCustomNativeException() {
 	public function testCustomNativeException() {