Fix TRY CATCH with RETURN.

This commit is contained in:
Volker Berlin 2022-06-12 21:02:43 +02:00
parent a46cbe2bc5
commit 4611474ec5
No known key found for this signature in database
GPG Key ID: 988423EF815BE4CB
2 changed files with 18 additions and 1 deletions

View File

@ -1170,9 +1170,14 @@ class BranchManager {
endPos = parsedBlock.endPosition;
break;
}
if( parsedBlock.startPosition > gotoPos ) {
break;
}
if( gotoPos < parsedBlock.endPosition && endPos > parsedBlock.endPosition ) {
endPos = parsedBlock.endPosition;
}
}
// define the try/catch/end block on the right position

View File

@ -1,5 +1,5 @@
/*
* Copyright 2018 - 2021 Volker Berlin (i-net software)
* Copyright 2018 - 2022 Volker Berlin (i-net software)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -57,6 +57,7 @@ public class Exceptions extends AbstractBaseTest {
addParam( list, script, "multiCatch" );
addParam( list, script, "multiCatch2" );
addParam( list, script, "serialCatch" );
addParam( list, script, "tryReturn" );
}
rule.setTestParameters( list );
rule.setProperty( JWebAssembly.WASM_USE_EH, "true" );
@ -245,6 +246,17 @@ public class Exceptions extends AbstractBaseTest {
return r;
}
@Export
static public int tryReturn() {
boolean flag = true;
try {
if( flag )
return 13;
} finally {
flag = true;
}
return 42;
}
// @Export
// static int npe() {