Commit 32a7e464 authored by Robert Griesemer's avatar Robert Griesemer

gofmt -r: match(...) arguments may be nil; add missing guards

Fixes #1446.

R=rsc
CC=golang-dev
https://golang.org/cl/3981043
parent 9ec785af
......@@ -124,9 +124,9 @@ func match(m map[string]reflect.Value, pattern, val reflect.Value) bool {
// Wildcard matches any expression. If it appears multiple
// times in the pattern, it must match the same expression
// each time.
if m != nil && pattern.Type() == identType {
if m != nil && pattern != nil && pattern.Type() == identType {
name := pattern.Interface().(*ast.Ident).Name
if isWildcard(name) {
if isWildcard(name) && val != nil {
// wildcards only match expressions
if _, ok := val.Interface().(ast.Expr); ok {
if old, ok := m[name]; ok {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment