Skip to content

Commit c7f2e99

Browse files
committed
Improve QLDoc for TypeAssertExpr
Include information about the type assert `x.(type)` used in type switches.
1 parent 698debf commit c7f2e99

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

go/ql/lib/semmle/go/Expr.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,13 +754,19 @@ class SliceExpr extends @sliceexpr, Expr {
754754
*
755755
* ```go
756756
* x.(T)
757+
* x.(type)
757758
* ```
758759
*/
759760
class TypeAssertExpr extends @typeassertexpr, Expr {
760761
/** Gets the base expression whose type is being asserted. */
761762
Expr getExpr() { result = this.getChildExpr(0) }
762763

763-
/** Gets the expression representing the asserted type. */
764+
/**
765+
* Gets the expression representing the asserted type.
766+
*
767+
* Note that this is not defined when the type assertion is of the form
768+
* `x.(type)`, as found in type switches.
769+
*/
764770
Expr getTypeExpr() { result = this.getChildExpr(1) }
765771

766772
override predicate mayHaveOwnSideEffects() { any() }

0 commit comments

Comments
 (0)