scala / scala/scala-parser-combinators

Declaration "class MyParser[A] extends RegexParsers with PackratParsers" does not compile

Open
#398 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
679
Forks
131
Avg merge
8h 25m
Merged PRs (30d)
3

Description

I wish to declare concrete class with a type parameter but scala compiler does not allow to do this if it extends both traits RegexParsers and PackratParsers simultaneously.
Compilation error says:

illegal trait super target found for method phrase required by trait PackratParsers;
[error]  found   : override def phrase: ([T](p: _1.Parser[T]): _1.Parser[T])( forSome { val _1: [A]MyParser[A] }) in trait RegexParsers;
[error]  expected: def phrase: ([T](p: _1.Parser[T]): _1.Parser[T])( forSome { val _1: [A]MyParser[A] }) in trait Parsers

Is there any way how to bypass this?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the generic MyParser[A] declaration shown in the issue, then inspect the RegexParsers and PackratParsers trait definitions involved in the phrase method error. Done means establishing whether the declaration can compile or documenting a supported workaround; the payload names no files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.