Hello!
Today I've discovered a in my opinion a bug. When you have rule 'Use FINAL for immutable variables' enabled and you try to format the code below:
method if_oo_adt_classrun~main.
types: begin of test_type,
attribute1 type string,
attribute2 type string,
end of test_type.
data tmp type test_type.
field-symbols <fieldx> type any.
data(struct) = cast cl_abap_structdescr( cl_abap_typedescr=>describe_by_data( p_data = tmp ) ).
data(shouldnt_be_final) = value test_type( attribute1 = 'test' ).
loop at struct->components into final(component).
assign component component-name of structure shouldnt_be_final to <fieldx>.
<fieldx> = 'will_fail'.
endloop.
endmethod.
then variable 'shouldnt_be_final' gets transformed into FINAL like this:
method if_oo_adt_classrun~main.
types: begin of test_type,
attribute1 type string,
attribute2 type string,
end of test_type.
data tmp type test_type.
field-symbols <fieldx> type any.
data(struct) = cast cl_abap_structdescr( cl_abap_typedescr=>describe_by_data( p_data = tmp ) ).
final(shouldnt_be_final) = value test_type( attribute1 = 'test' ).
loop at struct->components into final(component).
assign component component-name of structure shouldnt_be_final to <fieldx>.
<fieldx> = 'will_fail'.
endloop.
endmethod.
This will of course fail on runtime exception "MOVE_TO_LIT_NOTALLOWED_NODATA" and results in a short dump.
The issue seems to be, that ABAP Cleaner doesn't recognize changing of variable via field-symbol.
Could you please check this?
For the time being I was forced to turn off the formatting rule for FINAL.
My ABAP Cleaner version is currently 1.16.0
Thank you in advance.
With regards
Denis
Hello!
Today I've discovered a in my opinion a bug. When you have rule 'Use FINAL for immutable variables' enabled and you try to format the code below:
then variable 'shouldnt_be_final' gets transformed into FINAL like this:
This will of course fail on runtime exception "MOVE_TO_LIT_NOTALLOWED_NODATA" and results in a short dump.
The issue seems to be, that ABAP Cleaner doesn't recognize changing of variable via field-symbol.
Could you please check this?
For the time being I was forced to turn off the formatting rule for FINAL.
My ABAP Cleaner version is currently 1.16.0
Thank you in advance.
With regards
Denis