1 Commits
Author SHA1 Message Date
Michael PursifullandGitHub a0c6389b58 Guard ExpressionParser initialization with sync.Once (#2789)
* Guard ExpressionParser initialization with sync.Once

The evaluators call InitExpressionParser on every Evaluate, so two goroutines
could construct a parser at the same time. newParticipleLexer also fills in the
ParticipleTokenType field on each shared participleYqRules entry as it builds
the lexer, which another goroutine could be reading through getYqDefinition.

These are pointer and struct field writes rather than map writes, so the
runtime does not stop the process; it corrupts quietly instead.

The nil check stays inside the Once so a caller that assigns ExpressionParser
itself is still respected.

Fixes #2788

* docs: use UK spelling for initialised in new comments

Matches the existing prose convention in pkg/yqlib (operator_reduce.go,
decoder_ini.go, operator_alternative_test.go). Review feedback on #2789.
2026-08-03 12:51:40 +10:00