Bug #10248
Issue on RETURN ERROR STATEMENT on non-void OO method
100%
Related issues
History
#1 Updated by Greg Shah about 1 year ago
- Project changed from Conversion Tools to Base Language
#2 Updated by Teodor Gorghe about 1 year ago
We have this code:
...
CLASS tests.error_handling.TestCatchReturnCustomError:
@Test(expected="Progress.Lang.AppError":U).
METHOD PUBLIC VOID TestMethodCatchReturnCustomError ():
MethodCall().
END METHOD.
METHOD PUBLIC INTEGER MethodCall ():
RETURN ERROR NEW AppError("err1").
END METHOD.
END CLASS.
The
RETURN ERROR NEW AppError("err1") instruction gets converted into returnError().This issue does not happen on OO void method or procedures.
#4 Updated by Teodor Gorghe about 1 year ago
- Assignee set to Teodor Gorghe
- Status changed from New to WIP
Created task branch 10248a.
#5 Updated by Teodor Gorghe about 1 year ago
- Status changed from WIP to Review
- % Done changed from 0 to 100
- reviewer Constantin Asofiei added
Committed revision 16026 on task branch 10248a:
- Fix for RETURN ERROR statement on non-void method.
I have noticed that when I put RETURN ERROR on a getter/setter, the test passes on OE, but on FWD it does not pass the conversion:
Caused by: java.lang.NullPointerException: Cannot invoke "antlr.collections.AST.getType()" because the return value of "com.goldencode.expr.CompiledExpression.getVar(int)" is null
#6 Updated by Constantin Asofiei about 1 year ago
- Status changed from Review to Internal Test
I'm OK with the change.
#7 Updated by Constantin Asofiei about 1 year ago
For getter/setter - is it enough to add the same check as you did for 'method'?
#8 Updated by Teodor Gorghe about 1 year ago
Constantin Asofiei wrote:
For getter/setter - is it enough to add the same check as you did for 'method'?
No, it does not fix the issue.
#9 Updated by Teodor Gorghe about 1 year ago
- Status changed from Internal Test to WIP
After fixing the RETURN ERROR statement on non-void method, I have found in a customer application, a UNDO, RETURN ERROR statement which returns a OO object, which fails to compile.
Test case:
METHOD PUBLIC INTEGER MethodCall3 ():
DO TRANSACTION:
RETURN ERROR NEW AppError("dummy").
END.
Assert:IsTrue(FALSE).
CATCH aError AS Progress.Lang.Error :
UNDO, RETURN ERROR NEW AppError("err3").
END CATCH.
END METHOD.
Converted code:
@LegacySignature(type = Type.METHOD, name = "MethodCall3", returns = "INTEGER")
public integer methodCall3()
{
object<? extends LegacyError> aError_top = TypeFactory.object(LegacyError.class);
return function(TestCatchReturnCustomError.class, this, "MethodCall3", integer.class, new Block((Init) () ->
{
catchError(LegacyError.class,
aError ->
{
aError_top.assign(aError);
undoReturnErrorTopLevel(ObjectOps.newInstance(AppError.class, "I", "err3"));
});
},
(Body) () ->
{
doBlock(TransactionType.FULL, "blockLabel0", new Block((Body) () ->
{
{
returnError(ObjectOps.newInstance(AppError.class, "I", "dummy"));
}
}));
}));
}
Compilation error:
compile:
[javac] Compiling 51 source files to /home/tg/gcd/testcases2/testcases/build/classes
[javac] Compiling 1 source file to /home/tg/gcd/testcases2/testcases/build/classes
[javac] /home/tg/gcd/testcases2/testcases/src/com/goldencode/testcases/tests/error_handling/TestCatchReturnCustomError.java:119: error: no suitable method found for undoReturnErrorTopLevel(object<AppError>)
[javac] undoReturnErrorTopLevel(ObjectOps.newInstance(AppError.class, "I", "err3"));
[javac] ^
[javac] method BlockManager.undoReturnErrorTopLevel(String) is not applicable
[javac] (argument mismatch; no instance(s) of type variable(s) T exist so that object<T> conforms to String)
[javac] method BlockManager.undoReturnErrorTopLevel(character) is not applicable
[javac] (argument mismatch; no instance(s) of type variable(s) T exist so that object<T> conforms to character)
[javac] where T is a type-variable:
[javac] T extends _BaseObject_ declared in method <T>newInstance(Class<T>,String,Object...)
[javac] Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
[javac] 1 error
#10 Updated by Teodor Gorghe about 1 year ago
- Status changed from WIP to Review
Committed revision 16028 on task branch 10248a:
- Added undoReturnErrorTopLevel(BaseDataType) overload on UNDO, RETURN ERROR statement.
I have modified the test to check the execution after where the error is thrown and the test passes. Please let me know if there is something that I need to address. ABL code
#11 Updated by Teodor Gorghe about 1 year ago
Committed revision 16029 on task branch 10248a:
- Changed undoReturnErrorTopLevel(BaseDataType val) into undoReturnErrorTopLevel(object extends LegacyError> error). This should add more checks during compilation.
- Added a runtime check for error parameter.
Committed revision 16030 on task branch 10248a:
- Changed undoReturnErrorTopLevel(object extends LegacyError> error) to throw LegacyErrorException. This should fix the case having NO-ERROR statement on method call.
#12 Updated by Constantin Asofiei about 1 year ago
Please add history entry to BlockManager.
#13 Updated by Teodor Gorghe about 1 year ago
Committed revision 16031 on task branch 10248a:
- added history entry on BlockManager.java.
#14 Updated by Constantin Asofiei about 1 year ago
- Status changed from Review to Merge Pending
Please merge 10248a now.
#15 Updated by Teodor Gorghe about 1 year ago
- Status changed from Merge Pending to Test
Branch 10248a was merged to trunk revision 16050 and archived.
#16 Updated by Teodor Gorghe 9 months ago
- Related to Bug #10831: Incorrect handling of UNDO, RETURN ERROR <error> causes IllegalStateException to be thrown added