Is your bug report related to the C++ slang project or the pyslang Python bindings?
C++ slang
Describe the bug
If loop counter declared in for-loop initialization block the block statement in AST contains counter as member with initializer. As a result, when visiting the AST, information about the counter initial value is obtained before information about the presence of a loop.
To Reproduce
initial begin
for (int i = 0;;);
end
Additional context
According to the LRM (IEEE 1800-2023, section 12.7.1 The for-loop, the first example in section), these procedure blocks are equivalent:
initial begin
for (int i = 0; i <= 255; i++)
...
end
initial begin
begin
automatic int i;
for (i = 0; i <= 255; i++)
...
end
end
When constructing the AST, the initial value of i in the first case is stored as an initializer of the StatementBlockSymbol member, which appears in the AST before the ForLoopStatement. In the second case, the initial value of i can be obtained only from ForLoopStatement::initializers. The order in which the initial value of the loop counter is obtained affects the data flow analysis in the slang-tidy detector I am developing.
I suggest to uniform AST representation in both cases as it described by the standard.
Is your bug report related to the C++ slang project or the pyslang Python bindings?
C++ slang
Describe the bug
If loop counter declared in for-loop initialization block the block statement in AST contains counter as member with initializer. As a result, when visiting the AST, information about the counter initial value is obtained before information about the presence of a loop.
To Reproduce
Additional context
According to the LRM (IEEE 1800-2023, section
12.7.1 The for-loop, the first example in section), these procedure blocks are equivalent:When constructing the AST, the initial value of
iin the first case is stored as aninitializerof theStatementBlockSymbolmember, which appears in the AST before theForLoopStatement. In the second case, the initial value ofican be obtained only fromForLoopStatement::initializers. The order in which the initial value of the loop counter is obtained affects the data flow analysis in the slang-tidy detector I am developing.I suggest to uniform AST representation in both cases as it described by the standard.