Closed dboshardy closed 3 years ago
When specifying an occurrence style with a min > 0 and a token and the token not in the text being processed, the following panic happens:
occurrence
min
token
panic: runtime error: index out of range [0] with length 0 goroutine 13 [running]: github.com/errata-ai/vale/v2/internal/check.Occurrence.Run({{{{0x0, 0x0}, {0x0, 0x0, 0x0}}, {0x0, 0x0}, {0xc000988720, 0xa}, {0xc000988828, ...}, ...}, ...}, ...) github.com/errata-ai/vale/v2/internal/check/occurrence.go:66 +0x24b github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintBlock(0xc000a81918, 0xc00063e160, {{0xc0019fa900, 0x451}, 0xffffffffffffffff, {0xc001659860, 0x7}, {0xc0019fa900, 0x451}}, 0x21, ...) github.com/errata-ai/vale/v2/internal/lint/lint.go:225 +0x229 github.com/errata-ai/vale/v2/internal/lint.Linter.lintSizedScopes({0xc000620cc0, 0x0, 0x0, 0xc0004f9188, 0x1ea97a0, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...}, ...) github.com/errata-ai/vale/v2/internal/lint/ast.go:164 +0x411 github.com/errata-ai/vale/v2/internal/lint.Linter.lintHTMLTokens({0xc000620cc0, 0x0, 0x0, 0xc0004f9188, 0x1ea97a0, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...}, ...) github.com/errata-ai/vale/v2/internal/lint/ast.go:118 +0xb45 github.com/errata-ai/vale/v2/internal/lint.Linter.lintMarkdown({0xc000620cc0, 0x0, 0x0, 0xc0004f9188, 0x1ea97a0, {0x0, 0x0, 0x0}, {0x0, 0x0, ...}, ...}, ...) github.com/errata-ai/vale/v2/internal/lint/md.go:59 +0x194 github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintFile(0xc001097c80, {0x7ffeefbff525, 0xc0001081e0}) github.com/errata-ai/vale/v2/internal/lint/lint.go:174 +0x2f8 github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintFiles.func1.1.1({0x7ffeefbff525, 0x1}) github.com/errata-ai/vale/v2/internal/lint/lint.go:119 +0x5b created by github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintFiles.func1.1 github.com/errata-ai/vale/v2/internal/lint/lint.go:117 +0x21d
Looking at the source, it looks like loc is empty since no match is found.
loc
What snappy service! As I forked to fix this, I saw the fix was made to v2. Thanks!
v2
When specifying an
occurrence
style with amin
> 0 and atoken
and the token not in the text being processed, the following panic happens:Looking at the source, it looks like
loc
is empty since no match is found.