Version: trunk [r13331] (Linux x86_64). Component: native API.
A native routine or method that calls RaiseCondition(name, description, additional, NULLOBJECT) and then returns a value gives its caller no value at all, when the caller does not trap the condition or traps it with CALL ON: Error 44.1 ("No data returned from function") around a function call, 91.999 around an assignment. With a result object, that object is returned instead, as rexxapi says.
The Rexx equivalent returns the value. For example, the bridges that call Rexx code and then raise again, for their own caller, the condition that code raised:
::routine r
raise user oops description "d" return 7
In Rexx, x = r() gives x = 7, untrapped and under CALL ON USER OOPS (the handler runs), and the condition object has no RESULT index. A native routine that calls r through CallRoutine gets 7, raises the condition again with RaiseCondition("USER OOPS", "d", NULLOBJECT, NULLOBJECT) and returns 7: its caller gets Error 44.1. Passing the 7 as the result object works around it, but then the condition object has a RESULT that the Rexx one does not have.
Cause: NativeActivation::checkConditions(), for a pending non-SYNTAX condition that the caller does not trap with SIGNAL ON, sets the result from the condition object unconditionally:
result = (RexxObject *)conditionObj->get(GlobalNames::RESULT);
Without a RESULT index this is OREF_NULL, and the value the native code returned is dropped.
Fix: use RESULT only when the condition object has one; otherwise the value the native code returned stands. The same goes for RaiseConditionObject (RFE #883) with a condition object without RESULT.
Test: testRaiseConditionReturnValue in ooRexx/API/oo/METHOD.testGroup, with orxmethod's existing TestRaiseCondition (it raises the condition and returns 0): 0 without a result object, 7 with one, untrapped and under CALL ON (handler run).
Docs: rexxapi, RaiseCondition, argument obj: optional; without it, the routine or method result is the value it returns.
Results on [r13331], Linux, Release: METHOD.testGroup 351/351 with the fix (without it, the new test fails with 91.999); full test suite with no differences except the new test. Patches attached (main, test, docs).
Anonymous