Bug #10973
REGRESSION: No string literal to LONGCHAR conversion for 4GL class method call parameters
100%
Related issues
History
#1 Updated by Vladimir Tsichevski 8 months ago
This issue affects the FWD conversion when passing a CHARACTER literal as an argument to a class method expecting a LONGCHAR parameter. The converter omits the required new longchar(...) wrapper, causing a type mismatch in the generated Java code.
Conversion Test Case¶
Convert the following 4GL class (e.g., unittests/TestCharacterLiteralConversion.cls):
CLASS unittests.TestCharacterLiteralConversion:
METHOD PUBLIC VOID methodWithLongcharParameter(INPUT arg AS LONGCHAR):
RETURN.
END METHOD.
METHOD PUBLIC VOID test():
methodWithLongcharParameter('a').
END METHOD.
END CLASS.
This defines a method accepting LONGCHAR and calls it with a literal ('a').
Expected Behavior (Correct Conversion)¶
The generated Java should promote the literal via explicit LONGCHAR construction:
methodWithLongcharParameter(new longchar("a"));
Actual Behavior (FWD Converter)¶
The literal is passed directly as a Java String literal:
methodWithLongcharParameter("a");
This causes a compilation error (type mismatch: String not assignable to longchar).
#3 Updated by Vladimir Tsichevski 8 months ago
- Subject changed from No string literal to LONGCHAR conversion for 4GL class method call parameters to REGRESSION: No string literal to LONGCHAR conversion for 4GL class method call parameters
This is a regression, this issue did not exist in trunk rev. 14527 when the task #7184 was worked on.
#5 Updated by Vladimir Tsichevski 7 months ago
- Status changed from New to WIP
- % Done changed from 0 to 100
Vladimir Tsichevski wrote:
...the
longcharconstructor is applied two times to a string literal instead of one.
This fixed in 10973a rev. 16305.
When promoting a string literal to longchar (or similar type conversions) via constructor wrapping, ensure the literal is not already wrapped in a matching constructor call.