Skip to content

Preserve lazy extrema fallback and key arguments - #913

Open
vinsymoyya wants to merge 3 commits into
google:masterfrom
vinsymoyya:fix/lazy-extrema-arguments
Open

vinsymoyya wants to merge 3 commits into
google:masterfrom
vinsymoyya:fix/lazy-extrema-arguments

Conversation

@vinsymoyya

@vinsymoyya vinsymoyya commented Nov 14, 2026 •

Copy link
Copy Markdown

Fixes #910.

Preserve lazy minArray/maxArray arguments: ordinarily evaluate onEmpty only for an empty array, and evaluate/call keyF only when comparing elements. For example, std.minArray([2, 1], onEmpty=error 'unused') now returns 1, matching the canonical stdlib definition. A dedicated call adapter keeps the existing native extrema algorithms. Explicit tailstrict forces provided arguments and the implicit error default, preserving provided-argument error ordering.

Tests cover unused fallbacks and keys, singleton inputs, normal key-based selection, empty-input errors, and tailstrict defaults/error ordering. Ten cases fail on original production code and pass with the fix. The separate regression file is registered in Bazel.

Validation: focused regressions and go test -p=1 -buildvcs=false ./... pass on Go 1.24.13 Linux from the exact final commit archive; gofmt and git diff --check pass. Bazel and C/Python integration checks were not run locally.

This branch has not been deployed

No deployments
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.

Native extrema evaluate unused fallback and key arguments

1 participant