MCPcopy
hub / github.com/uber-go/nilaway / RichCheckEffect

Interface RichCheckEffect

assertion/function/assertiontree/rich_check_effect.go:42–63  ·  view source on GitHub ↗

A RichCheckEffect is the fact that a certain check is associated with an effect that can be triggered by a conditional, for example the `ok` in `v, ok := m[k]` the functions `effectIfTrue` and `effectIfFalse` are analogous to the respective returns from `AddNilCheck` - functions that are marked as

Source from the content-addressed store, hash-verified

40// the effect. Whether an expression invalidates this effect is determined by the interface function
41// `isInvalidatedBy`.
42type RichCheckEffect interface {
43 // isTriggeredBy indicates whether a given expression in a conditional is sufficient to trigger
44 // this `RichCheckEffect`
45 isTriggeredBy(expr ast.Expr) bool
46
47 // isInvalidatedBy indicates whether a given expression invalidates this effect
48 isInvalidatedBy(node ast.Node) bool
49
50 // effectIfTrue is the effect to insert as preprocessing in the true branch of a triggering conditional
51 effectIfTrue(node *RootAssertionNode)
52
53 // effectIfFalse is the effect to insert as preprocessing in the false branch of a triggering condition
54 effectIfFalse(node *RootAssertionNode)
55
56 // isNoop returns whether this effect is a noop (i.e. placeholder value)
57 isNoop() bool
58
59 // equals returns true iff this effect should be considered equal to another
60 // correctness of these `equals` functions is vital to correctness (and termination) of the propagation
61 // in `propagateRichChecks`.
62 equals(RichCheckEffect) bool
63}
64
65// A FuncErrRet is a RichCheckEffect for the `err` in `r0, r1, r2, ..., err := f()`, where the
66// function `f` has a final result of type `error` - and until this is checked all other results are

Callers 6

propagateRichChecksFunction · 0.65
stripNoopsFunction · 0.65
addFunction · 0.65
mergeSlicesFunction · 0.65

Implementers 4

FuncErrRetassertion/function/assertiontree/rich_
FuncErrRetNonnilArgassertion/function/assertiontree/rich_
okReadassertion/function/assertiontree/rich_
RichCheckNoopassertion/function/assertiontree/rich_

Calls

no outgoing calls

Tested by

no test coverage detected