-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
Bug: Expressions in DIMENSION
attribute of arrays inside a SUBROUTINE
lead to an ASR verify pass error
#4013
Comments
Do you think it's due to the dimension-shape not being a constant at compile time? |
Thank you @assem2002 , I had missed the module part of the issue. I have updated the code. The previous code had failed when the dimension was not an expression. |
It's still the same problem though. If you figure out any fix inform me, I will look up this issue too and I'll keep updated. |
The code compiles and executes properly with GFortran. It compiles with LFortran when we replace |
it got confusing when found out it works with |
Yes! The previous code I had provided was incorrect. The issue here has a module in the picture too. The above is the correct code. |
I think a variation of this bug was fixed by @Pranavchiku in #3962. Maybe the fix does not work if the module is compiled separately? |
I tried the MRE provided in #3962. From what I have observed, setting array dimension works with module variables, but not when we convert it to an expression. So, doing (lf) saurabh-kumar@Awadh:~/Projects/System/lfortran$ lfortran ./examples/example.f90
ASR verify pass error: ASR::ttype_t in ASR::FunctionType cannot be tied to a scope.
--> ./examples/example.f90:5:1 - 9:14
|
5 | subroutine a(cs)
| ^^^^^^^^^^^^^^^^...
...
|
9 | end subroutine
| ...^^^^^^^^^^^^^^ failed here
Note: Please report unclear, confusing or incorrect messages as bugs at
https://github.com/lfortran/lfortran/issues. Given that we already have a fix for it's base case in #3962, I think this should be easy to fix. I am trying to fix this. |
@certik got this. This is an issue with handling binary integer operations inside the dimension attribute. I am pushing a fix in a while. (base) saurabh-kumar@Awadh:~/Projects/System/lfortran$ lfortran ./examples/example.f90
integer binop
ASR verify pass error: ASR::ttype_t in ASR::FunctionType cannot be tied to a scope.
--> ./examples/example.f90:5:1 - 9:14
|
5 | subroutine a(cs)
| ^^^^^^^^^^^^^^^^...
...
|
9 | end subroutine
| ...^^^^^^^^^^^^^^ failed here
Note: Please report unclear, confusing or incorrect messages as bugs at
https://github.com/lfortran/lfortran/issues. |
Yes, handling binary operation will do the job. Just transfer it to something like “INTEGER, DIMENSION(get_nx()-1) :: n” |
An approach to fix this is to create a |
Let me have a look into it! 👍 |
i’ll ask you to get current PR to finish line. |
Minimum Reproducible Example (MRE)
Output
The bug was caught when trying to compile file
expxs.f90
of the SNAP package.The subroutine
expxs_slgg ( scat, map, cs )
causes the above error due to the parametercs
which is declared asREAL(r_knd), DIMENSION(cmom-1,nx), INTENT(OUT) :: cs
. On further analysis, we find that the expressioncmom-1
is the cause of the issue. Other similar expressions likecmom+1
,cmom * 2
, etc also lead to the above error. We can simplify the issue to the MRE provided above.The text was updated successfully, but these errors were encountered: