Skip to content
Draft
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
6 changes: 4 additions & 2 deletions unified/ql/lib/codeql/unified/internal/LocalNameBinding.qll
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ private module LocalNameBindingInput implements LocalNameBindingInputSig<Locatio
child = stmt.(GuardIfStmt).getElse() and
i2 = -1 // place before condition so its variables are not seen
or
not stmt instanceof GuardIfStmt and
// Include the statements themselves. Guard statements must also be included, as
// `getChild` would otherwise add them with their original index, which may
// clash with the indices assigned here.
child = stmt and
i2 = 0
i2 = -2
)
|
child order by i1, i2
Expand Down
12 changes: 12 additions & 0 deletions unified/ql/test/query-tests/unusedentities/test.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,15 @@ func t2() -> Int {
let b = 2 // $ Alert[unified/unused-variable]
})
}

class C {
func x() -> Int? { return nil }

func t3() -> Bool {
guard let x = x() else { return false }
let succeeded = true
guard succeeded else { return false }
print(x)
return true
}
}
Loading