Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions go/ql/lib/semmle/go/controlflow/ControlFlowGraphImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ module CfgImpl {
e.(Go::PromotedSelector).refersTo(explicitField) and
baseType.getFieldAtDepth(_, explicitFieldDepth) = explicitField
|
index = explicitFieldDepth - implicitFieldDepth
index = explicitFieldDepth - implicitFieldDepth and index > 0
)
)
or
Expand All @@ -689,7 +689,8 @@ module CfgImpl {
baseType = e.(Go::PromotedSelector).getSelectedStructType() and
e.(Go::PromotedSelector).refersTo(method) and
baseType.getMethodAtDepth(_, mDepth) = method and
index = mDepth - implicitFieldDepth
index = mDepth - implicitFieldDepth and
index > 0
|
method = baseType.getMethodOfEmbedded(implicitField, _, implicitFieldDepth + 1)
or
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,21 @@ func test19() mystruct {
return mystruct{test10(1), test10(2) == 2} // $ Alert
}

type (
embedded struct{}
recursive struct {
*embedded
value int
*recursive
}
)

func test20(x *recursive) []int {
values := []int{0}
if x.value != 0 {
values = append(values, x.value)
}
return values // OK: reachable because value is a direct field of recursive
}

func main() {}
Loading