-
Notifications
You must be signed in to change notification settings - Fork 166
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
Allow global variable initialisation only using the compile_item value #1672
Allow global variable initialisation only using the compile_item value #1672
Conversation
Otherwise, use an assignment statement to initialize the variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using your PR, please show the indented ASR for this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(TranslationUnit
(SymbolTable
1
{
_global_symbols:
(Module
(SymbolTable
5
{
_lpython_main_program:
(Function
(SymbolTable
4
{
})
_lpython_main_program
(FunctionType
[]
()
Source
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
[]
.false.
)
[test]
[]
[(=
(Var 5 x)
(FunctionCall
5 test
()
[]
(Integer 4 [])
()
()
)
()
)
(=
(Var 5 j)
(Var 5 i)
()
)]
()
Public
.false.
.false.
),
i:
(Variable
5
i
[]
Local
(IntegerConstant 10 (Integer 4 []))
(IntegerConstant 10 (Integer 4 []))
Default
(Integer 4 [])
Source
Public
Required
.false.
),
j:
(Variable
5
j
[]
Local
()
()
Default
(Integer 4 [])
Source
Public
Required
.false.
),
test:
(Function
(SymbolTable
2
{
_lpython_return_variable:
(Variable
2
_lpython_return_variable
[]
ReturnVar
()
()
Default
(Integer 4 [])
Source
Public
Required
.false.
),
temp:
(Variable
2
temp
[]
Local
()
()
Default
(Integer 4 [])
Source
Public
Required
.false.
)
})
test
(FunctionType
[]
(Integer 4 [])
Source
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
[]
.false.
)
[]
[]
[(=
(Var 2 temp)
(IntegerConstant 0 (Integer 4 []))
()
)
(=
(Var 2 _lpython_return_variable)
(Var 2 temp)
()
)
(Return)]
(Var 2 _lpython_return_variable)
Public
.false.
.false.
),
x:
(Variable
5
x
[]
Local
()
()
Default
(Integer 4 [])
Source
Public
Required
.false.
)
})
_global_symbols
[]
.false.
.false.
),
main_program:
(Program
(SymbolTable
3
{
_lpython_main_program:
(ExternalSymbol
3
_lpython_main_program
5 _lpython_main_program
_global_symbols
[]
_lpython_main_program
Public
)
})
main_program
[_global_symbols]
[(SubroutineCall
3 _lpython_main_program
()
[]
()
)]
)
})
[]
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me.
Thanks of the approvals! |
Fixes: #1667