mirror of
https://github.com/github/codeql.git
synced 2025-12-17 17:23:36 +01:00
Once again, the interaction between anchors and extras (specifically comments) was causing trouble. The root of the problem was the fact that in `a[b]`, we put `b` in the `index` field of the subscript node, whereas in `a[b,c]`, we additionally synthesize a `Tuple` node for `b,c` (which matches the Python AST). To fix this, we refactored the grammar slightly so as to make that tuple explicit, such that a subscript node either contains a single expression or the newly added tuple node. This greatly simplifies the logic.
22 lines
158 B
Python
22 lines
158 B
Python
a[b]
|
|
|
|
c[d,e]
|
|
|
|
c1[d1,]
|
|
|
|
# And now with many comments
|
|
|
|
e[
|
|
# comment1
|
|
f
|
|
# comment2
|
|
]
|
|
|
|
g[
|
|
# comment3
|
|
h,
|
|
# comment4
|
|
i
|
|
# comment5
|
|
]
|