Skip to content

Commit 197dfc9

Browse files
committed
Check the length of p.capnamelist when assigning slots
1 parent 07e7dfa commit 197dfc9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

syntax/parser.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ func (p *parser) noteCaptureName(name string, pos int) {
238238
func (p *parser) assignNameSlots() {
239239
if p.useMaintainCaptureOrder() {
240240
p.capnames = p.capnamenums
241-
// Prepend `0` to capnamelist if it's not set
242-
if p.capnamelist[0] != `0` {
241+
// Prepend `0` to capnamelist if it's not set (MaintainCaptureOrder was enabled inline)
242+
if len(p.capnamelist) == 0 || p.capnamelist[0] != `0` {
243243
p.capnamelist = append([]string{fmt.Sprint(0)}, p.capnamelist...)
244244
}
245245
} else {

0 commit comments

Comments
 (0)