Skip to content

fix: make example solutions compile with V 0.5.2 - #308

Merged
keiravillekode merged 1 commit into
exercism:mainfrom
metif12:fix/v-052-compile-fixes
Sep 28, 2026
Merged

keiravillekode merged 1 commit into
exercism:mainfrom
metif12:fix/v-052-compile-fixes

Conversation

@metif12

@metif12 metif12 commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

What

Three example/test files that no longer compiled against a current V. Split out of #307 so it can be reviewed and merged on its own.

Exercise Problem Fix
allergies sorted_with_compare() on a []Allergen makes V emit calls to the builtin compare(int*, int*); the C backend rejects the pointer types. run_test.v sorts a mapped []int instead, so no custom compare is needed.
intergalactic-transmission u8 << int is now widened to int, so add_parity(current) received an int where a u8 is required. Cast the packed byte back with u8(...).
zebra-puzzle constraint !in queue.array() — the in operator on an array of structs generates an int vs struct comparison in C. Replaced with an explicit .any() predicate over the fields that identify a constraint.

Verification

Verified on both ends of the supported version range, so this is safe to merge independently of a V upgrade in the test runner:

  • bin/verify-exercises-in-docker (the current vlang-test-runner image, V 0.4.8): all three pass.
  • V 0.5.2, the version vlang/setup-v installs for bin/test in CI: all three pass.

configlet lint passes, and v fmt -l / v vet are clean on the touched files.

Note for the merge commit

Please do not add [no important files changed]. These three exercises previously failed to compile, so students' existing solutions for them get re-tested and can now report a real result instead of a build error.

- allergies: replace sorted_with_compare() in run_test.v. V 0.5.2 emits
  calls to the builtin compare(int*, int*) when a custom compare function
  is used with a non-int element type, which fails in the C backend.
  Sorting a mapped []int instead avoids the broken codegen.
- intergalactic-transmission: u8 shift results are now widened to int,
  so cast the packed byte back to u8 before handing it to add_parity().
- zebra-puzzle: the 'in' operator on an array of structs generates a
  comparison between int and the struct in C. Use an explicit any()
  predicate comparing the fields that identify a constraint.
@github-actions

Copy link
Copy Markdown
Contributor

This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested.

If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos.

[no important files changed]

For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping @exercism/maintainers-admin in a comment. Thank you!

@keiravillekode
keiravillekode merged commit 80ed861 into exercism:main Sep 28, 2026
7 checks passed
@metif12 metif12 mentioned this pull request Oct 1, 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.

2 participants