Description
Problem Description:
The sgf-parsing
exercise currently fails to compile due to a Not Found Error
for scala.util.parsing.combinator.RegexParsers
. This issue appears to be a direct result of the track's migration from Scala 2.12 (or earlier) to Scala 3.
A typical error message encountered is:
[E008] Not Found Error: /path/to/Sgf.scala:2:18
2 |import scala.util.parsing.combinator.RegexParsers
| ^^^^^^^^^^^^^^^^^^
| Not found: type parsing
Root Cause:
Starting with Scala 2.13, the scala-parser-combinators
library was modularized and extracted from the standard library. Consequently, it is no longer available by default in Scala 3. Any code relying on RegexParsers
or other classes from this package now requires an explicit dependency to be added to the project's build configuration.
The current test runner and build environment for this exercise have not been updated to include this dependency, making the provided stub and example solutions that use RegexParsers
uncompilable.
Suggested Actions for Resolution:
To make this exercise solvable again for students, the maintainers will need to update the exercise's configuration. There are two potential paths forward:
Option 1: Add the Missing Dependency (Recommended for fastest fix)
The most direct solution is to add the scala-parser-combinators
library to the exercise's build configuration.
- Modify
build.sbt
: Add the following line to thebuild.sbt
file for thesgf-parsing
exercise:(Note: VersionlibraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.3.0"
2.3.0
is the latest version compatible with Scala 3. Please verify the appropriate version at the time of fix.)
Option 2: Modernize the Exercise (Long-term improvement)
While adding the dependency is a quick fix, it relies on a library that is no longer considered the standard for parsing in modern Scala. A more forward-looking solution would be to update the exercise to use a contemporary parsing approach.
- Update Stub and Example Solution: Rewrite the exercise stub and reference solution to not depend on
scala-parser-combinators
. This could involve:- Using a modern, high-performance parsing library like FastParse or Cats Parse. This would require adding one of those dependencies instead.
- Rewriting the solution to use standard string manipulation and
scala.util.matching.Regex
. This would remove external dependencies entirely and test a different set of skills.
- Update Documentation: The exercise's
.docs/instructions.md
and hint files may need to be updated to guide the student towards the new expected approach.
Given the goal of getting the track back to a fully working state, Option 1 is likely the most pragmatic first step.