mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Python: Fix parenthesized tuple parser bug
We were writing the `parenthesised` attribute twice on tuples, once because of the explicit parenthetisation, and once because all non-empty tuples are parenthesised. This made `tree-sitter-graph` unhappy. To fix this, we now explicitly check whether a tuple is already parenthesised, and do nothing if that is the case.
This commit is contained in:
@@ -35,3 +35,5 @@ t, u,
|
||||
x, y,
|
||||
#comment
|
||||
)
|
||||
|
||||
((z,))
|
||||
|
||||
@@ -3485,5 +3485,9 @@
|
||||
|
||||
[(tuple element: (_)) (tuple_pattern)] @tup
|
||||
{
|
||||
attr (@tup.node) parenthesised = #true
|
||||
; In order to avoid writing to the `parenthesised` attribute twice, we only set it here
|
||||
; if the surrounding expression is not a `parenthesized_expression`.
|
||||
if (not (instance-of (get-parent @tup) "parenthesized_expression")) {
|
||||
attr (@tup.node) parenthesised = #true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user