Skip to content

jq: skip rejects generator counts instead of applying count fan-out #2934

Description

@newhoggy

Severity: Low

Summary

The skip(n; f) extension rejects a generator count instead of running its body once per count. This predates #2863; accepting the bare-comma spelling does not introduce the evaluator gap.

Repro

Verified on #2863's base 1fc023b0c and its fixed branch:

printf 'null' | succinctly jq -c '[skip((0,1); 10,20,30)]'
# exit 5, no stdout; expected number, got null

The same query in yq mode with --jq-extensions -o=json -I0 exits 1 with the same diagnostic. jq 1.7.1 rejects skip/2 as undefined, so this is extension behavior rather than a pinned-oracle divergence. The intended per-count result is [10,20,30,20,30].

Root cause

src/jq/eval.rs:15742, builtin_skip: eval_single can return a multi-value result, but count classification only handles a single number; the multi-value result falls into the null/error fallback.

Why this is separate from #2863

#2863 changes argument parsing and removes shadow-retry exhaustion. This evaluator defect already reproduces with the previously accepted parenthesized spelling and requires count fan-out independently.

Suggested fix direction

Route the count through the shared argument fan-out machinery, preserving input and output order for each count. Cover zero/positive/negative counts, empty and erroring count generators, and truncating consumers. Use builtin_ltrimstr's fanout_arg and each_nth's demand-forwarding fanout_arg_each as existing patterns; decide whether the sink twin is needed as part of that investigation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions