Skip to content

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

Open
@rabestro

Description

@rabestro

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.

  1. Modify build.sbt: Add the following line to the build.sbt file for the sgf-parsing exercise:
    libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "2.3.0"
    (Note: Version 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.

  1. 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.
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions