Skip to content

Native extrema evaluate unused fallback and key arguments #910

Open

Description

@vinsymoyya

The native extrema functions evaluate arguments that the canonical stdlib leaves unused. Reproduced on master 567b61ac4a6c23546a62d79324bb4aaed6bdc941:

std.minArray([2, 1], onEmpty=error 'unused')

This reports RUNTIME ERROR: unused instead of returning 1. maxArray has the same problem. Empty arrays also evaluate an unused keyF even when onEmpty is provided, and singleton arrays invoke a key function that cannot affect the result.

The canonical minArray/maxArray definitions only evaluate onEmpty for empty input and only use keyF when comparing elements. A native call adapter can preserve those conditions while retaining the optimized extrema algorithms and explicit tailstrict argument forcing.

Regression cases fail on current production code; a focused fix passes unused-argument cases, ordinary extrema, empty-input errors, and explicit tailstrict checks.

Activity

  1. vinsymoyya commented on Nov 14, 2026

    @vinsymoyya
    Author

    Opened #913 with a native call adapter that keeps unused fallbacks and keys lazy while retaining the existing extrema algorithms. Explicit tailstrict forces both provided arguments and the implicit error default, with provided-argument errors retaining their order.

    Ten regression cases fail against the original code and pass with the fix. The focused tests and full Linux Go suite pass; the PR records the remaining Bazel/C/Python integration checks.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions