Skip to content

Commit

Permalink
Explicitly upcast intermediate result to aid program elaboration (#230)
Browse files Browse the repository at this point in the history
See scala/scala3#18130 for context.

We add an explicit type ascription to help the compiler infer contextual arguments.
  • Loading branch information
julienrf committed Jul 10, 2023
1 parent 7111c61 commit 3204411
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/src/main/scala/weaponregex/parser/ParserJVM.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ class ParserJVM private[parser] (pattern: String) extends Parser(pattern) {
* `"[abc]"`
*/
override def charClass[A: P]: P[CharacterClass] =
Indexed("[" ~ "^".!.? ~ (charClassIntersection.rep(exactly = 1) | classItem.rep(minCharClassItem)) ~ "]")
Indexed(
"[" ~ "^".!.? ~ ((charClassIntersection.rep(exactly = 1): P[Seq[RegexTree]]) | classItem.rep(
minCharClassItem
)) ~ "]"
)
.map { case (loc, (hat, nodes)) => CharacterClass(nodes, loc, isPositive = hat.isEmpty) }

/** Intermediate parsing rule for special construct tokens which can parse either `namedGroup`, `nonCapturingGroup`,
Expand Down

0 comments on commit 3204411

Please sign in to comment.