diff --git a/regex/compile.go b/regex/compile.go index 0429c37..fa51e0d 100644 --- a/regex/compile.go +++ b/regex/compile.go @@ -987,7 +987,8 @@ func thompson(re []postfixNode) (Reg, error) { if c.nodetype == charclassNode { // A Character class consists of all the nodes in it, alternated // Map the list of nodes to a list of states, each state containing the contents of a specific node states := funcMap(c.nodeContents, func(node postfixNode) *nfaState { - s := newState() + s := &nfaState{} + s.output = append(s.output, s) nodeContents := node.contents if caseInsensitive { nodeContents = slices.Concat(funcMap(nodeContents, func(r rune) []rune { @@ -1001,7 +1002,7 @@ func thompson(re []postfixNode) (Reg, error) { return n.contents })...) } - return &s + return s }) // Reduce the list of states down to a single state by alternating them toAdd := funcReduce(states, func(s1 *nfaState, s2 *nfaState) *nfaState {