Skip to content

Commit 7efffd7

Browse files
authored
Replace exists with explicit nil check (#10)
1 parent 185aeb9 commit 7efffd7

File tree

3 files changed

+2
-10
lines changed

3 files changed

+2
-10
lines changed

internal/compiler/ast.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package compiler
22

3-
import "reflect"
4-
53
// Visitor
64

75
type Visitor func(*Node) bool
@@ -22,12 +20,6 @@ func visitNodes(v Visitor, nodes []*Node) bool {
2220
return false
2321
}
2422

25-
// In situations where conversions from a pointer type may produce a typed nil, this function can be used
26-
// to check that the interface truly references an existing struct.
27-
func exists(i interface{}) bool {
28-
return !(i == nil || reflect.ValueOf(i).IsNil())
29-
}
30-
3123
// NodeFactory
3224

3325
type NodeFactory struct {

internal/compiler/binder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ func finishFlowLabel(label *FlowLabel) *FlowNode {
572572
}
573573

574574
func (b *Binder) bind(node *Node) bool {
575-
if !exists(node) {
575+
if node == nil {
576576
return false
577577
}
578578
node.parent = b.parent

internal/compiler/utilities.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ func isClassLike(node *Node) bool {
10001000
}
10011001

10021002
func declarationNameToString(name *Node) string {
1003-
if !exists(name) || name.Pos() == name.End() {
1003+
if name == nil || name.Pos() == name.End() {
10041004
return "(Missing)"
10051005
}
10061006
return getTextOfNode(name)

0 commit comments

Comments
 (0)