Skip to content

Commit edfe5f3

Browse files
committed
Elaborate QL doc for stepLanguageSpecific
1 parent 9e9b988 commit edfe5f3

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

‎shared/typeinference/codeql/typeinference/internal/TypeInference.qll‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,8 +2444,21 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
24442444
*
24452445
* Use this predicate to implement any language-specific bottom-up inference logic.
24462446
*
2447-
* When contextual type information is needed at `n1`, this predicate may additionally
2448-
* be applied _reversely_ as well (see an example in the module documentation).
2447+
* For example, in Rust one may implement the following two rules for the `?` operator:
2448+
*
2449+
* ```text
2450+
* x : Option<T> x : Result<T, E>
2451+
* ----------------- --------------------
2452+
* x? : T x? : T
2453+
* ```
2454+
*
2455+
* The rules examplify how the converse only holds when `n1` already has an inferred type
2456+
* that matches `prefix1`; knowing that `x?` has type `i32` does not necessarily imply that
2457+
* `x` has type `Option<i32>` or `Result<i32, _>`, we can only conclude this if we know
2458+
* that `x` has root type `Option` or `Result`, respectively.
2459+
*
2460+
* When contextual type information is needed at `n1`, this predicate may be applied
2461+
* _reversely_ (see an example in the module documentation).
24492462
*/
24502463
predicate stepLanguageSpecific(AstNode n1, TypePath prefix1, AstNode n2, TypePath prefix2);
24512464

0 commit comments

Comments
 (0)