Repository navigation
fix: make example solutions compile with V 0.5.2 - #308
Merged
Merged
Conversation
- 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.
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. For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping |
keiravillekode
approved these changes
Sep 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
allergiessorted_with_compare()on a[]Allergenmakes V emit calls to the builtincompare(int*, int*); the C backend rejects the pointer types.run_test.vsorts a mapped[]intinstead, so no customcompareis needed.intergalactic-transmissionu8 << intis now widened toint, soadd_parity(current)received anintwhere au8is required.u8(...).zebra-puzzleconstraint !in queue.array()— theinoperator on an array of structs generates anintvs struct comparison in C..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 currentvlang-test-runnerimage, V 0.4.8): all three pass.vlang/setup-vinstalls forbin/testin CI: all three pass.configlet lintpasses, andv fmt -l/v vetare 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.