Skip to content

Add scala-parser-combinators dependency - #63

Merged
rabestro merged 2 commits into
mainfrom
add-parser-combinators-dependency
Aug 27, 2026
Merged

Add scala-parser-combinators dependency#63
rabestro merged 2 commits into
mainfrom
add-parser-combinators-dependency

Conversation

@rabestro

Copy link
Copy Markdown
Member

Fixes exercism/scala#863.

The problem

bin/run.sh compiles a student's solution against the assembly jar and nothing else:

scalac -classpath "${test_runner_jar}" -d "${workdir_target}" \
    "${workdir}"/src/main/scala/* "${workdir}"/src/test/scala/*

The exercise's own build.sbt is never read, so a library an exercise needs has to be one of this project's dependencies — which is why monocle is already here for LensPerson.

scala-parser-combinators was not. The sgf-parsing stub imports scala.util.parsing.combinator.RegexParsers, and that package left the standard library in Scala 2.13. So since the track moved to Scala 3 in exercism/scala#836, sgf-parsing has failed to compile online even for a student who has not edited the stub at all:

-- [E008] Not Found Error: src/main/scala/Sgf.scala:1:18
1 |import scala.util.parsing.combinator.RegexParsers
  |       ^^^^^^^^^^^^^^^^^^
  |       value parsing is not a member of util

Locally the exercise works, because there sbt does read its build.sbt — which is why this only ever showed up as a report from the website.

The change

Adds scala-parser-combinators outside the Test scope so sbt assembly puts it in the fat jar, following the existing comment on that block.

Version 2.4.0 is the current release and the one the track's own root build.sbt already uses. Four more exercises — alphametics, forth, matching-brackets and wordy — declare the same dependency for their example solutions, so they are covered by the same change.

Verification

Reconstructing the old classpath (scalatest, scalacheck, org.json, monocle — 28 jars, no parser-combinators) and compiling the untouched sgf-parsing stub with Scala 3.4.2 reproduces the [E008] error above. Against the newly assembled jar the same files compile clean.

bin/run-tests-in-docker.sh passes, all 10 fixtures:

example-all-fail          example-numeric-test-name
example-custom-class      example-partial-fail
example-empty-file        example-sgf-parsing
example-lens-person       example-success
example-multiple-tests    example-syntax-error

新建 fixture

tests/example-sgf-parsing is a trimmed parser-combinator solution with six tests, mirroring how example-lens-person guards the monocle dependency. Without the dependency this fixture fails to compile, so a regression is caught by CI rather than by a student.

Note: sbt test reports 2 pre-existing failures in ApplicationSpec (testResultsFiles is null, Application.scala:76). They fail identically on main and are unrelated to this change.

关注-up, not in this PR

The five exercises in exercism/scala pin scala-parser-combinators at 2.1.0 in their own build.sbt, so local runs resolve 2.1.0 while the runner now provides 2.4.0. Harmless for RegexParsers, but worth aligning in a track-side PR.

bin/run.sh compiles a solution against the assembly jar only and never
reads the exercise's own build.sbt, so a library an exercise needs has to
be part of this project's dependencies (as monocle already is for
LensPerson).

The sgf-parsing stub imports scala.util.parsing.combinator.RegexParsers,
which has not been in the standard library since Scala 2.13. Since the
track moved to Scala 3 the exercise therefore fails to compile online
even when the student has not touched it:

  -- [E008] Not Found Error: src/main/scala/Sgf.scala:1:18
  1 |import scala.util.parsing.combinator.RegexParsers
    |       ^^^^^^^^^^^^^^^^^^
    |       value parsing is not a member of util

alphametics, forth, matching-brackets and wordy declare the same
dependency for their example solutions, so they are covered too.

Version 2.4.0 matches the one the track's own root build.sbt uses.

Adds a tests/example-sgf-parsing fixture so a missing parser-combinators
dependency fails the test suite instead of only surfacing in production.

Fixes exercism/scala#863

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@rabestro
rabestro requested a review from a team as a code owner August 27, 2026 16:20
Comment thread tests/example-sgf-parsing/expected_results.json Outdated
@rabestro rabestro self-assigned this Aug 27, 2026
@rabestro
rabestro merged commit 7cdfab7 into main Aug 27, 2026
1 check passed
@rabestro
rabestro deleted the add-parser-combinators-dependency branch August 27, 2026 17:01
注册 for free to join this conversation on GitHub. Already have an account? 登录 to comment

标签

None yet

项目

None yet

Development

Successfully merging this pull request may close these issues.

SGF Parsing exercise is broken due to missing scala-parser-combinators dependency after Scala 3 migration

2 participants