Skip to content

style: reformat exercise sources with the V 0.5.2 formatter - #324

Merged
kahgoh merged 1 commit into
exercism:mainfrom
metif12:style/v-052-fmt
Oct 3, 2026
Merged

kahgoh merged 1 commit into
exercism:mainfrom
metif12:style/v-052-fmt

Conversation

@metif12

@metif12 metif12 commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

What

The v fmt pass, on its own. It is the last piece of #307 that is not a new exercise, so it can be reviewed and merged without any of them.

v fmt in V 0.5.2 does five things to the exercise sources:

  • aligns the values of consecutive struct fields
  • writes double-quoted strings as single-quoted ones
  • drops the parentheses around an if expression that is returned
  • adds a trailing comma to the last element of a multiline array literal
  • removes the blank line at the start of an empty function body

30 files across 27 exercises. grade-school.v and robot-name.v are left alone: the <TYPE> placeholders in them cannot be parsed by the formatter.

Why this is safe to merge

None of it changes what the code does. V treats '...' and ... the same way, and none of the rewritten strings contains a quote or an escape, so the two forms are equivalent here. The rest is indentation, a comma and a pair of parentheses.

Verified for every exercise this touches:

  • bin/verify-exercises-in-docker (the current vlang-test-runner image, V 0.4.8): pass
  • V 0.5.2, the version vlang/setup-v installs for bin/test in CI: pass
  • configlet lint passes; v fmt -l and v vet are clean on all 30 files

For the merge commit

Please add:

[no important files changed]

The test outcomes of these exercises are identical before and after, so there is no reason to re-run the existing student solutions.

@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!

fn test_verse__single_verse__first_generic_verse() {
expected :=
("Ten green bottles hanging on the wall,
("Ten green bottles hanging on the wall,

@kahgoh kahgoh Oct 1, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Curious, what does v version output for you?

I just did a quick test by pulling your changes down and running v fmt -w on this file. I was expecting to see no diff, but I got this diff at this location:

@@ -1,8 +1,7 @@
 module main
 
 fn test_verse__single_verse__first_generic_verse() {
-       expected :=
-               ("Ten green bottles hanging on the wall,
+       expected := ("Ten green bottles hanging on the wall,
 Ten green bottles hanging on the wall,
 And if one green bottle should accidentally fall,
 There'll be nine green bottles hanging on the wall.")

There were similar diff through the file. I wasn't sure if this was coming down to the the V version. For reference, mine outputs:

V 0.5.2 7647ce1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

PS C:\Users\MR> v version
V 0.5.2 3a4d9d3

v is evolving very fast and some time update minutely. so the output if you keep up with master is never the same.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it turn out that:

  • 7647ce1 — the 0.5.2 tag, 2026-07-13
  • 3a4d9d3 — master HEAD, 2026-10-02
    so the same version but different commit.
    and fmt output change time to time, so the only way of keep it repeatable is pin the commit.

@keiravillekode

Copy link
Copy Markdown
Contributor

Please use

commit 7647ce1c6fad63b5578bc07883139906de74b2f8 (tag: 0.5.2)

and run v fmt again.

Regenerate the vfmt pass against commit 7647ce1
(tag: 0.5.2), as requested in review, and rebase it on current main. The previous
pass was produced by a master build; the version string alone did not distinguish
the two, since v.mod still reads 0.5.2 on master.

Rebasing onto main dropped most of the old diff: the example solutions that the
earlier revision touched are already clean under this build, which also fixed
them for V 0.5.2. Seven files remain:

  bottle-song, dominoes, intergalactic-transmission
      line joining and removal of a blank line at the start of an empty body
  knapsack, palindrome-products, saddle-points, word-search
      alignment of consecutive struct field values

No semantic changes: no & or mut dropped, no argument count change, no comma
moved inside a multiline literal.

Verified with v built from 7647ce1:

  - v fmt is idempotent on the result
  - bin/test passes on all 114 practice exercises
  - the 7 touched exercises pass in exercism/vlang-test-runner, which also
    reports V 0.5.2 7647ce1
  - configlet lint passes
@metif12

metif12 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

built from commit 7647ce1c6fad63b5578bc07883139906de74b2f8

[no important files changed]

@keiravillekode

Copy link
Copy Markdown
Contributor

I will leave this review for kahgoh.

The next work item will be one of the new practice exercises: save-the-cow.

@kahgoh kahgoh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good

@kahgoh
kahgoh merged commit 984ba51 into exercism:main Oct 3, 2026
9 of 10 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.

3 participants