mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Python: Fix some more async parsing problems
Turns out we were not setting the `is_async` field on anything except `async for` statements. This commit makes it so that we also do this for `async def` and `async with`, and adds a test that this produces the same behaviour as the old parser.
This commit is contained in:
@@ -2650,6 +2650,14 @@
|
||||
let @with.first = @first.node
|
||||
}
|
||||
|
||||
; Async status
|
||||
; NOTE: We only set the `is_async` field on the _first_ clause of the `with` statement,
|
||||
; as this is the behaviour of the old parser.
|
||||
(with_statement "async" "with" @with_keyword (with_clause . (with_item) @with))
|
||||
{
|
||||
attr (@with.node) is_async = #true
|
||||
}
|
||||
|
||||
(with_item
|
||||
value: (_) @value
|
||||
) @with
|
||||
@@ -3253,6 +3261,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
; Async status
|
||||
(function_definition "async" "def" @def_keyword) @funcdef
|
||||
{
|
||||
let start = (location-start @def_keyword)
|
||||
attr (@funcdef.function) is_async = #true
|
||||
attr (@funcdef.node) _location_start = start
|
||||
attr (@funcdef.function) _location_start = start
|
||||
attr (@funcdef.funcexpr) _location_start = start
|
||||
}
|
||||
|
||||
;;; Decorators
|
||||
|
||||
(decorated_definition
|
||||
|
||||
Reference in New Issue
Block a user