Skip to content

Commit 8e27904

Browse files
committed
Python: Add explanatory comment.
1 parent 3463889 commit 8e27904

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

python/ql/src/experimental/dataflow/internal/DataFlowPrivate.qll

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,39 @@ private Node update(Node node) {
245245
// Global flow
246246
//--------
247247
//
248-
/** Computes routing of arguments to parameters */
248+
/**
249+
* Computes routing of arguments to parameters
250+
*
251+
* When a call contains more positional arguments than there are positional parameters,
252+
* the extra positional arguments are passed as a tuple to a starred parameter. This is
253+
* achieved by synthesising a node `TPosOverflowNode(call, callable)`
254+
* that represents the tuple of extra positional arguments. There is a store step from each
255+
* extra positional argument to this node.
256+
*
257+
* CURRENTLY NOT SUPPORTED:
258+
* When a call contains a tuple argument, it is expanded into positional arguments.
259+
*
260+
* CURRENTLY NOT SUPPORTED:
261+
* Whe a call contains a tuple argument and the callee contains a starred argument, any extra
262+
* positional arguments are passed to the starred argument.
263+
*
264+
* When a call contains keyword arguments that do not correspond to keyword parameters, these
265+
* extra keyword arguments are passed as a dictionary to a doubly starred parameter. This is
266+
* achieved by synthesising a node `TKwOverflowNode(call, callable)`
267+
* that represents the dictionary of extra keyword arguments. There is a store step from each
268+
* extra keyword argument to this node.
269+
*
270+
* When a call contains a dictionary argument with entries corresponding to a keyword parameter,
271+
* the value at such a key is unpacked and passed to the positional parameter. This is achieved
272+
* by synthesising an argument node `TKwUnpacked(call, callable, name)` representing the unpacked
273+
* value. This is used as the argument passed to the matching keyword parameter. There is a read
274+
* step from the dictionary argument to the synthesized argument node.
275+
*
276+
* When a call contains a dictionary argument and the callee contains a doubly starred parameter,
277+
* entries which are not unpacked are passed to the doubly starred parameter. This is achieved by
278+
* adding a dataflow step from the dictionary argument to `TKwOverflowNode(call, callable)` and a
279+
* step to clear content of that node at any unpacked keys.
280+
*/
249281
module ArgumentPassing {
250282
/**
251283
* Gets the `n`th parameter of `callable`.
@@ -288,7 +320,7 @@ module ArgumentPassing {
288320
* Gets the argument to `call` that is passed to the `n`th parameter of `callable`.
289321
* If it is a positional argument, it must appear at position `argNr`.
290322
* `argNr` will differ from `n` for method- or class calls, where the first parameter
291-
* is `self` and the first positional arguemnt is passed to the second positional parameter.
323+
* is `self` and the first positional argument is passed to the second positional parameter.
292324
*/
293325
Node getArg(CallNode call, int argNr, CallableValue callable, int n) {
294326
connects(call, callable) and

0 commit comments

Comments
 (0)