The indentation of comments is currently parsed according to preceding and relative to other statements to try to place comments at the right level but it ends up affecting following lines of code.
produces this AST. The common placement is correct, but notice how the expression statement is lacking one indentation level.
(source [0, 0] - [4, 0]
(function_definition [0, 0] - [3, 54]
name: (name [0, 5] - [0, 13])
parameters: (parameters [0, 13] - [0, 15])
return_type: (type [0, 19] - [0, 23]
(identifier [0, 19] - [0, 23]))
body: (body [0, 24] - [3, 54]
(if_statement [1, 1] - [1, 9]
condition: (true [1, 4] - [1, 8])
body: (body [1, 9] - [1, 9]))
(comment [2, 1] - [2, 11])
(expression_statement [3, 2] - [3, 54]
(call [3, 2] - [3, 54]
(identifier [3, 2] - [3, 7])
arguments: (arguments [3, 7] - [3, 54]
(string [3, 8] - [3, 53])))))))
Places all the comments at zero indentation level, while they should be respectively at 0, 1, 2, 3, and 4.
The indentation of comments is currently parsed according to preceding and relative to other statements to try to place comments at the right level but it ends up affecting following lines of code.
For example this code:
produces this AST. The common placement is correct, but notice how the expression statement is lacking one indentation level.
Then this:
Places all the comments at zero indentation level, while they should be respectively at 0, 1, 2, 3, and 4.
Related issues: