Skip to content

Rearrange local declarations leading to syntax error #64

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
zmsMarc opened this issue Jun 19, 2023 · 4 comments
Closed

Rearrange local declarations leading to syntax error #64

zmsMarc opened this issue Jun 19, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@zmsMarc
Copy link

zmsMarc commented Jun 19, 2023

Settings: Default
grafik

I was working on changes to AbapOpenCheck 06 (https://github.com/larshp/abapOpenChecks/blob/main/src/checks/zcl_aoc_check_06.clas.abap) and noticed a syntax error after AbapCleaner re-ordered the local declarations.

Here's an example with the basic structure before:
grafik

And after Cleanup:
grafik

Notice the field symbol declaration is now before the data statement it references.

Maybe there needs to be an additional check on usages of LIKE LINE OF.

@jmgrassau jmgrassau added the bug Something isn't working label Jun 19, 2023
@jmgrassau
Copy link
Member

Hi Marc,

thanks a lot for reporting this! The rule already tries to consider LIKE dependencies, but apparently, it gets confused by the BEGIN OF ... END OF in the DATA chain. As a minimal example to trigger the bug, I found:

  METHOD any_method.
    DATA: BEGIN OF ls_struc,
            comp TYPE i,
          END OF ls_struc,
          lt_table TYPE STANDARD TABLE OF ty_s_any WITH DEFAULT KEY.

    FIELD-SYMBOLS <ls_any> LIKE LINE OF lt_table.

    rv_result = ls_struc-comp + lines( lt_table ) + <ls_any>-comp.
  ENDMETHOD.

Will fix this, of course!

Kind regards,
Jörg-Michael

@jmgrassau jmgrassau self-assigned this Jun 23, 2023
@jmgrassau
Copy link
Member

Hi Marc,

thanks again for this finding! This will be fixed in the next release – the rule now double-checks that a declaration is not moved in front of the declaration it refers to with LIKE.

Kind regards,
Jörg-Michael

@zmsMarc
Copy link
Author

zmsMarc commented Jun 23, 2023

Thanks as always for the quick solution!

@jmgrassau
Copy link
Member

Hi Marc,

version 1.4.1 was just released and should fix this!

Kind regards,
Jörg-Michael

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants