Bug #7200
fix INIT and LABEL for LIKE defined fields or variables
0%
Related issues
History
#2 Updated by Roger Borrello about 1 year ago
- Related to Bug #5288: Some date field character comparisons have runtime incompatibilities during runtime added
#3 Updated by Roger Borrello about 1 year ago
- File initializer_var_like_field.p added
- File initializer_field_like_var.p added
- File 7190_both-side-by-side.png added
Testcases are checked into old testcases and attached.
Interestingly, the code using the fields as the "model" (initializer_var_like_field.p
) properly initializes the field holding the date given "1.1" as the initial value:
field f5b as date init 1.1 ... /*def var vf5a like tt1.f5a.*/ def var vf5b like tt1.f5b.
and becomes:
@LegacySignature(type = Type.VARIABLE, name = "vf5b") /*def var vf5a like tt1.f5a.*/ <-- BTW, this comment should be above the LegacySignature date vf5b = UndoableFactory.date();
Whereas the variable being the "model" for the field (initializer_var_like_field.p
):
def var vf5b as date init 1.1. .. /*field f5a like vf5a*/ field f5b like vf5b
becomes:
@LegacySignature(type = Type.VARIABLE, name = "vf5b") /*def var vf5a as date init 0.*/ date vf5b = UndoableFactory.date(date.fromLiteral("1.1"));
The 4GL has "1.1" become the data "1/1/yy" where yy is the current year (23).
In walking through the code, the fromLiteral
ends up constructing using date()
since the format isn't recognized:
public static date fromLiteral(String str) { Matcher matcher = literalPattern.matcher(str); if (!matcher.matches()) { return new date(); // format not recognized ...
That ends up just returning a
date
containing unknown
, and then that ends up going through the deepAssign
:Daemon Thread [Conversation [00000005:bogus]] (Suspended) date.deepAssign(date) line: 2567 date.<init>(date) line: 668 TypeFactory.date(date) line: 575 UndoableFactory.date(date) line: 486 InitializerLikeTest.<init>() line: 84 InitializerLikeTestConstructorAccess.newInstance() line: not available ...
For the case where the field is the model, we don't go through the same path and the output of the variable is the correct "01/01/23":
Daemon Thread [Conversation [00000006:bogus]] (Suspended) TypeFactory.date() line: 521 UndoableFactory.date() line: 422 InitializerLikeTestReverse.<init>() line: 84 InitializerLikeTestReverseConstructorAccess.newInstance() line: not available ...
In any case, what we seem to have are fields in the table that are formatted more correctly than in the variables (initializer_field_like_var.p
on left initializer_var_like_field.p
on right):