Open certik opened 2 years ago
I think its a problem with ASR verify because if you read the error message then g
is actually present in f
's dependency list but verify isn't able to figure that out. Let me see what I can do to fix it. Self-assigning.
Well its not a bug with dependency tracker. If I disable that check I get the following ASR for f
,
f:
(Function
(SymbolTable
3
{
_lpython_return_variable:
(Variable
3
_lpython_return_variable
ReturnVar
()
()
Default
(Integer 4 [])
Source
Public
Required
.false.
)
})
f
[]
[]
[(=
(Var 3 _lpython_return_variable)
(IntegerConstant 42 (Integer 4 []))
()
)
(Return)]
(Var 3 _lpython_return_variable)
Source
Public
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
[]
.false.
)
As you can see 2 + g()
statement is absent in the final ASR. So probably the bug is in AST to ASR transition.
So the question is how to deal with statements (or should we call target-less expressions?) of the kind 2 + g()
. I think they should be present in the ASR because g()
might be modifying a non-constant global variable so not executing 2 + g()
is a mistake I think.
My conclusion - This is not a bug with dependency tracker because ASR itself is incomplete so verify is bound to fail anyways.
Yes, the 2+g()
must be represented in ASR. I think the immediate solution is https://github.com/lcompilers/lpython/issues/1232#issuecomment-1293624014, that is, adding an Expr stmt node.
The following code:
Gives: