Skip to content

Restrict expression references to function arguments - #396

Closed
Narek-Khachikyan wants to merge 1 commit into
jmespath:developfrom
Narek-Khachikyan:fix/expref-argument-context
Closed

Narek-Khachikyan wants to merge 1 commit into
jmespath:developfrom
Narek-Khachikyan:fix/expref-argument-context

Conversation

@Narek-Khachikyan

Copy link
Copy Markdown

Summary

search("[&foo]", {}) returns a list containing an internal _Expression object, and length([&foo]) silently returns 1.

_token_nud_expref registers & as a generic expression prefix even though expression-type is only an alternative of function-arg. Moving its parsing to the argument parser enforces the correct grammar context.

Expected: Compilation raises ParseError for & outside a direct function-argument position; map(&foo, items) and nested map calls remain valid.

- parse & as an expression prefix everywhere
+ parse & directly at function argument positions

Evidence

JMESPATH_TEST=tests/compliance/expref_context.json .tox/campaign/bin/python -m pytest tests/test_compliance.py -q --tb=short detects the baseline error and passes with the fix; the full pytest suite with branch coverage passes.

Merge Danger

Door: two-way. Focused correction with regression tests; no new API.

Blast Radius: parsing.

@Narek-Khachikyan Narek-Khachikyan closed this by deleting the head repository Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant