Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Check suggestion - Predicate function return type in IF expression #1009

Open
nomssi opened this issue Mar 3, 2021 · 1 comment
Open

Check suggestion - Predicate function return type in IF expression #1009

nomssi opened this issue Mar 3, 2021 · 1 comment

Comments

@nomssi
Copy link

nomssi commented Mar 3, 2021

We can use a predicate method call IS_EOF( ) in an IF expression as

          IF is_eof( ).
            str = '<eof>'.
          ELSE.
            str = format_string( value ).
          ENDIF.

This will be interpreted as

          IF is_eof( ) IS NOT INITIAL.

Let us assume the method IS_EOF( ) returns an object type with two constant values

          CLASS-DATA true TYPE REF TO lcl_boolean .
          CLASS-DATA false TYPE REF TO lcl_boolean.

The code should now be changed to

          IF is_eof( ) EQ true.

to be correct. The issue is that

          IF is_eof( ) .

will not trigger any error/warning from the syntax check. The code will silently fail.

Could you create a check for this case?

@larshp
Copy link
Owner

larshp commented Mar 4, 2021

yes

so, but, I do see this as a scenario for data flow analysis, that the return value of the function can take two values, and INITIAL is not one of these. Data flow analysis is difficult in ABAP, but I am starting to have some good infrastructure in https://abaplint.org so it might be possible to add there, sometime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants