diff --git a/cmd/globdraw/main.go b/cmd/globdraw/main.go index d268372..ce5a76e 100644 --- a/cmd/globdraw/main.go +++ b/cmd/globdraw/main.go @@ -54,7 +54,7 @@ func main() { for _, c := range strings.Split(*sep, ",") { r, w := utf8.DecodeRuneInString(c) if len(c) > w { - fmt.Println("only single charactered separators are allowed: %+q", c) + fmt.Printf("only single charactered separators are allowed: %+q\n", c) os.Exit(1) } separators = append(separators, r) diff --git a/compiler/compiler_test.go b/compiler/compiler_test.go index 3f00e2e..e982077 100644 --- a/compiler/compiler_test.go +++ b/compiler/compiler_test.go @@ -113,7 +113,7 @@ func TestCompiler(t *testing.T) { match.NewSingle(separators), }), match.NewAny(separators), - nil, + match.Nothing{}, ), }, { @@ -129,13 +129,13 @@ func TestCompiler(t *testing.T) { sep: separators, exp: match.NewTree( match.NewText("/"), - nil, + match.Nothing{}, match.NewTree( match.MustIndexedAnyOf( match.NewText("z"), match.NewText("ab"), ), - nil, + match.Nothing{}, match.NewSuper(), ), ), @@ -156,7 +156,7 @@ func TestCompiler(t *testing.T) { match.NewSingle(separators), }), match.NewSuper(), - nil, + match.Nothing{}, ), }, { @@ -273,7 +273,7 @@ func TestCompiler(t *testing.T) { ), exp: match.NewTree( match.NewText("abc"), - nil, + match.Nothing{}, match.NewAnyOf( match.NewSingle(nil), match.NewList([]rune{'d', 'e', 'f'}, false), @@ -293,7 +293,7 @@ func TestCompiler(t *testing.T) { match.NewRange('a', 'z', false), match.NewRange('a', 'x', true), }), - nil, + match.Nothing{}, match.NewSuper(), ), }, diff --git a/match/optimize.go b/match/optimize.go index 2dad6e5..61f880a 100644 --- a/match/optimize.go +++ b/match/optimize.go @@ -40,8 +40,8 @@ func Optimize(m Matcher) (opt Matcher) { } var ( - leftNil = v.left == nil - rightNil = v.right == nil + leftNil = v.left == nil || v.left == Nothing{} + rightNil = v.right == nil || v.right == Nothing{} ) if leftNil && rightNil { return NewText(txt.s)