danielbodart opened a new pull request, #3636: URL: https://github.com/apache/tinkerpop/pull/3636
## What `inject()` is the only variadic-generic step in the Gremlin grammar that rejects a bound variable. This changes both `inject` productions from `genericLiteralVarargs` to `genericArgumentVarargs`, so `inject(<variable>)` parses and resolves like every sibling step. ## Why (consistency) A `…Argument` rule is exactly `literal | variable` — the `variable` alternative is the bound parameter. Counting who uses which variadic-generic rule in `Gremlin.g4`: - **`genericArgumentVarargs`** (accepts a bound variable) is used by `V()`, `E()` (spawn and mid-traversal), `hasId()`, `hasValue()`, `property()`, and — the closest structural twin — `within()` / `without()`. - **`genericLiteralVarargs`** (literal-only) is referenced by **nothing but the two `inject` productions**. So `inject` is the lone holdout: its nearest sibling `within()`, which does the identical "spray a list of values in" job, already accepts a bound parameter. This aligns `inject` with the rest of the language rather than adding anything new to it. ## Compatibility Strict superset. `genericArgument` includes `genericLiteral` (maps included), so every existing `inject(...)` call parses and behaves exactly as before; only the previously-rejected `inject(<variable>)` becomes valid. Verified against the existing negative grammar corpus (`incorrect-gremlin-values.txt`) — it contains no bare identifiers, so nothing moves from "correctly rejected" to "now accepted." ## Changes - **Grammar** (`Gremlin.g4`): both `inject` productions → `genericArgumentVarargs`. - **Reference visitors** (`TraversalSourceSpawnMethodVisitor`, `TraversalMethodVisitor`): route through `ArgumentVisitor.parseObjectVarargs(ctx.genericArgumentVarargs())`, identical to how `V()`/`E()` already work. - **Groovy translators** (Java + JavaScript): the `inject(x, null)` Groovy-closure disambiguation walked a `genericLiteralExpr` layer that `genericArgumentVarargs` doesn't have (the args sit directly under the varargs node); adapted to the flatter shape. Output is unchanged for all existing cases including `inject(1, null)`. - **Tests**: grammar-level parse cases for `g.inject(x)` / `g.V().inject(x)` (`BasicGrammarTest`), and an end-to-end variable-resolution assertion in `GremlinQueryParserTest.shouldParseVariablesInVarargs` mirroring the existing `g.V(x, y, 300)` case. - **CHANGELOG** entry. The now-orphaned `genericLiteralVarargs` rule is left in place (harmless; its context class is still generated, keeping `GenericLiteralVisitor`/`DefaultGremlinBaseVisitor` compiling) — happy to remove it if preferred. ## Notes - No JIRA filed yet — glad to open one if that's preferred for tracking. - Generated ANTLR parsers (all language targets) are build-time artifacts and will regenerate from the grammar; no committed generated code changed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Hca9vdARjSU8bM4JRbcWXT -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
