Skip to content

binary-search: make the stub signature match the tests - #602

Merged
keiravillekode merged 1 commit into
exercism:mainfrom
pakgin:fix/binary-search
Nov 19, 2026
Merged

keiravillekode merged 1 commit into
exercism:mainfrom
pakgin:fix/binary-search

Conversation

@pakgin

@pakgin pakgin commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Summary

The binary-search stub declares

pub fn binarySearch(target: usize, items: []const usize) ?usize

but the tests and .meta/example.zig call it generically, as binarySearch(T, target, items).
So when a student runs the tests against the untouched stub, the first error comes from the test file, not the stub's "please implement" message:

test_binary_search.zig:7:52: error: expected 2 argument(s), found 3

The stub currently works around this with a comment ("Take a look at the tests, you might have to change the function arguments").
No other stub in the track has a comment like this.
The other generic exercises (strain, linked-list, circular-buffer, complex-numbers) give the comptime T: type signature in the stub.

This PR changes the stub to the signature the tests expect and removes the comment:

pub fn binarySearch(comptime T: type, target: T, items: []const T) ?usize

Testing

  • zig test test_binary_search.zig against the new stub fails only on the intended @compileError("please implement the binarySearch function")
  • .meta/example.zig still passes all 11 tests (unchanged)
  • zig fmt --check passes

Impact on existing solutions

Only binary_search.zig, the exercise's solution file, changes.
No test, editor or invalidator files are touched, so merging this should not re-run existing student solutions.

Forum discussion: https://forum.exercism.org/t/binary-search-stub-function-signature-doesnt-match-the-tests/99761

@github-actions

Copy link
Copy Markdown
Contributor

Hello. Thanks for opening a PR on Exercism 🙂

We ask that all changes to Exercism are discussed on our Community Forum before being opened on GitHub. To enforce this, we automatically close all PRs that are submitted. That doesn't mean your PR is rejected but that we want the initial discussion about it to happen on our forum where a wide range of key contributors across the Exercism ecosystem can weigh in.

You can use this link to copy this into a new topic on the forum. If we decide the PR is appropriate, we'll reopen it and continue with it, so please don't delete your local branch.

If you're interested in learning more about this auto-responder, please read this blog post.


Note: If this PR has been pre-approved, please link back to this PR on the forum thread and a maintainer or staff member will reopen it.

@github-actions github-actions Bot closed this Nov 19, 2026

@keiravillekode keiravillekode left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keiravillekode
keiravillekode merged commit 2084e30 into exercism:main Nov 19, 2026
14 checks passed
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.

2 participants