Skip to content

Commit d754133

Browse files
committed
pattern: guard against impossible comparisons with strings and tokens
1 parent 50b05f5 commit d754133

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pattern/match.go

+3
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,9 @@ func matchNodeAST(m *Matcher, a Node, b interface{}) (interface{}, bool) {
373373
return b, true
374374
case nil:
375375
return nil, a == Nil{}
376+
case string, token.Token:
377+
// 'a' can't be a String, Token, or Binding or we'd be using their Match implementations.
378+
return nil, false
376379
default:
377380
panic(fmt.Sprintf("unhandled type %T", b))
378381
}

0 commit comments

Comments
 (0)