errata-ai / vale

:pencil: A markup-aware linter for prose built with speed and extensibility in mind.
https://vale.sh
MIT License
4.52k stars 155 forks source link

Error while adding additional dictionaries #808

Open puneet-ekline opened 7 months ago

puneet-ekline commented 7 months ago

Check for existing issues

Environment

macOS vale version 2.29.7

Describe the bug / provide steps to reproduce it

Here is the spelling error rule

extends: spelling
message: "'%s' could be a typo!"
dicpath: ./dics
dictionaries:
  - en_us

Running this rule on a content repo, results in the following error

$> vale ./src/content
panic: runtime error: slice bounds out of range [-1:]

goroutine 41 [running]:
github.com/errata-ai/vale/v2/internal/core.(*File).assignLoc(_, {_, _}, {{0xc0064b8f00, 0x2390}, 0xdb, {0xc00363f6a0, 0x8}, {0xc00363f6a0, 0x8}, ...}, ...)
        github.com/errata-ai/vale/v2/internal/core/file.go:212 +0x2b8
github.com/errata-ai/vale/v2/internal/core.(*File).AddAlert(_, {{{0x0, 0x0}, {0x0, 0x0, 0x0}}, {0xc00363f6e0, 0x2, 0x2}, {0x0, ...}, ...}, ...)
        github.com/errata-ai/vale/v2/internal/core/file.go:256 +0x2ca
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintBlock(0xc002659ca8, 0xc006498000, {{0xc0064b8f00, 0x2390}, 0xdb, {0xc00363f6a0, 0x8}, {0xc00363f6a0, 0x8}, {0xc005a98640, ...}}, ...)
        github.com/errata-ai/vale/v2/internal/lint/lint.go:265 +0x368
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintProse(0xc002659828?, 0xc006498000, {{0xc0064b8f00, 0x2390}, 0xdb, {0x1895700, 0x3}, {0x1895700, 0x3}, {0xc005a98640, ...}}, ...)
        github.com/errata-ai/vale/v2/internal/lint/lint.go:231 +0x1b1
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintScope(0xc005a98640?, 0xc006498000, 0xc0064a8f30, {0xc005a98640, 0x9d})
        github.com/errata-ai/vale/v2/internal/lint/ast.go:155 +0x27e
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintHTMLTokens(0xc002659ca8, 0xc006498000, {0xc0064ae000, 0x24f2, 0x4000}, 0xc0064822a0?)
        github.com/errata-ai/vale/v2/internal/lint/ast.go:112 +0x718
github.com/errata-ai/vale/v2/internal/lint.Linter.lintMarkdown({{0x0, 0x0, 0x0}, {0x0, 0x0, 0x0}, 0xc002e70700, 0xc0028de018, 0x24b9ba0, 0x1, ...}, ...)
        github.com/errata-ai/vale/v2/internal/lint/md.go:72 +0x1a5
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintFile(0xc0000a60f0, {0xc005d972c0?, 0x4?})
        github.com/errata-ai/vale/v2/internal/lint/lint.go:181 +0x2dd
github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintFiles.func1.1.1({0xc005d972c0?, 0x4?})
        github.com/errata-ai/vale/v2/internal/lint/lint.go:125 +0x58
created by github.com/errata-ai/vale/v2/internal/lint.(*Linter).lintFiles.func1.1 in goroutine 8
        github.com/errata-ai/vale/v2/internal/lint/lint.go:123 +0x1e9