CodeQL library for Go
codeql/go-all 2.1.3-dev (changelog, source)
Search

Class ResultVariableDecl

A result variable declaration.

Examples:

int
string
error
r io.Reader
output string
err error
x, y int

as in the following code:

func f1() int { return 0 }
func f2(input string) (string, error) { return "", nil }
func f3(a int) (r io.Reader) { return nil }
func f4(input string) (output string, err error) { return}
func f5(e error) (x, y int) { return }

Note: x, y int is a single ResultVariableDecl even though it declares two different result variables. Use the member predicate getTypeExpr() to get int, getNameExpr(0) to get x and getNameExpr(1) to get y.

Import path

import semmle.go.Decls

Direct supertypes

Indirect supertypes

Inherited fields

Predicates

getAPrimaryQlClass

Gets the name of a primary CodeQL class to which this node belongs.

getIndex

Gets the index of this result variable declaration among all result variable declarations of its associated function type.

toString

Gets a textual representation of this element.

Inherited predicates

getAChild

Gets a child node of this node.

from AstNode
getAChildExpr

Gets an expression that is a child node of this node in the AST.

from ExprParent
getANameExpr

Gets an expression representing the name of a variable declared in this declaration.

from ParameterOrResultDecl
getChild

Gets the ith child node of this node.

from AstNode
getChildExpr

Gets the ith child expression of this node.

from ExprParent
getDocumentation

Gets the documentation comment group attached to this element, if any.

from Documentable
getEnclosingFunction

Gets the innermost function definition to which this AST node belongs, if any.

from AstNode
getFile

Gets the file this program element comes from.

from Locatable
getFunction

Gets the function to which this declaration belongs.

from ParameterOrResultDecl
getFunctionTypeExpr

Gets the function type expression to which this declaration belongs.

from ParameterOrResultDecl
getLocation

Gets this element’s location.

from Locatable
getNameExpr

Gets the expression representing the name of the ith variable declared in this declaration (0-based).

from ParameterOrResultDecl
getNumChild

Gets the number of child nodes of this node.

from AstNode
getNumChildExpr

Gets the number of child expressions of this node.

from ExprParent
getNumLines

Gets the number of lines covered by this element.

from Locatable
getParent

Gets the parent node of this AST node, if any.

from AstNode
getPrimaryQlClasses

Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.

from AstNode
getType

Gets the type of the fields declared in this declaration.

from FieldBase
getTypeExpr

Gets the expression representing the type of the fields declared in this declaration.

from FieldBase
getUniquelyNumberedChild

Get an AstNode child, ordered by child kind and then by index.

from AstNode
hasLocationInfo

Holds if this element is at the specified location. The location spans column startcolumn of line startline to column endcolumn of line endline in file filepath. For more information, see Locations.

from Locatable

Charpred