Skip to content

Commit

Permalink
Fix shadowing warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
satabin committed May 13, 2024
1 parent 71f7e33 commit 4bc4424
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ object ValueParser {
chunk(idx) match {
case CborItem.Break =>
Pull.pure((chunk, idx + 1, rest, chunkAcc, CborValue.TextString(acc.result())))
case CborItem.TextString(text) =>
if (acc.size + text.size < 0) {
case CborItem.TextString(txt) =>
if (acc.size + txt.size < 0) {
raise(new CborParsingException(s"text string size is limited to max int (${Int.MaxValue}) characters"),
chunkAcc)
} else {
parseTextStrings(chunk, idx + 1, rest, acc.append(text), chunkAcc)
parseTextStrings(chunk, idx + 1, rest, acc.append(txt), chunkAcc)
}
case item =>
raise(new CborParsingException(s"unexpected item $item"), chunkAcc)
Expand Down
8 changes: 4 additions & 4 deletions finite-state/shared/src/main/scala/fs2/data/mft/MFT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ private[data] class MFT[Guard, InTag, OutTag](init: Int, val rules: Map[Int, Rul
findAllCalls(rhs).flatMap { case Rhs.Call(q1, _, args) =>
val usedInQ1 = usedParams.getOrElse(q1, Set())
args.zipWithIndex.collect {
case (rhs, i) if usedInQ1.contains(i) =>
bareOccurences(rhs)
case (rhs1, i) if usedInQ1.contains(i) =>
bareOccurences(rhs1)
}
}
}.combineAll
Expand Down Expand Up @@ -198,8 +198,8 @@ private[data] class MFT[Guard, InTag, OutTag](init: Int, val rules: Map[Int, Rul
rhs match {
case Rhs.Call(q, x, args) =>
stayStates.get(q) match {
case Some(rhs) =>
subst(rhs, x, args.map(inlineStayCalls(_)))
case Some(rhs1) =>
subst(rhs1, x, args.map(inlineStayCalls(_)))
case None => rhs
}
case Rhs.Node(t, children) => Rhs.Node(t, inlineStayCalls(children))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ sealed trait DecisionTree[Expr, Tag, Out] {
skel.select(on) match {
case Some(c) =>
branches.get(c.tag) match {
case Some(tree) => loop(tree)
case Some(tree1) => loop(tree1)
case None =>
fallBack match {
case Some(tree) => loop(tree)
case None => None
case Some(tree1) => loop(tree1)
case None => None
}
}
case None =>
fallBack match {
case Some(tree) => loop(tree)
case None => None
case Some(tree1) => loop(tree1)
case None => None
}
}
case _ => None
Expand Down
6 changes: 3 additions & 3 deletions finite-state/shared/src/main/scala/fs2/data/pfsa/PDFA.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ private[data] class PDFA[P, T](val init: Int,
if (q >= transitions.length)
None
else
transitions(q).collectFirst { case (p, q) if p.satisfies(t) => q }
transitions(q).collectFirst { case (p, q1) if p.satisfies(t) => q1 }

def recognizes[S[_]: Foldable](input: S[T]): Boolean =
input
.foldLeftM((init, 0)) { case ((q, idx), c) =>
transitions
.lift(q)
.flatMap(_.collectFirst {
case (p, q) if p.satisfies(c) =>
(q, idx + 1)
case (p, q1) if p.satisfies(c) =>
(q1, idx + 1)
})
}
.exists { case (q, idx) =>
Expand Down
4 changes: 2 additions & 2 deletions finite-state/shared/src/main/scala/fs2/data/pfsa/PNFA.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ private[data] class PNFA[P, T](val init: Int, val finals: Set[Int], val transiti
val newStates1 = newStates.updated(q, newQ)
val ts = q.toList
.flatMap(transitions.get(_))
.flatMap(_.collect { case (Some(p), q) =>
(p, q)
.flatMap(_.collect { case (Some(p), q1) =>
(p, q1)
})
.groupBy(_._1)
.fmap(_.map(_._2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ sealed abstract class Regular[CharSet] {
case Some(c) =>
val tgt = re.derive(c)
val equivalent = qs.zipWithIndex.collectFirst {
case (q, idx) if tgt === q => idx
case (q1, idx) if tgt === q1 => idx
}
equivalent match {
case Some(tgt) => (qs, transitions.combine(Map(q -> List(cs -> tgt))))
case Some(tgt1) => (qs, transitions.combine(Map(q -> List(cs -> tgt1))))
case None =>
val qs1 = qs.append(tgt)
val q1 = qs.size.toInt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ private[json] object TokenSelector {
Pull.raiseError(JsonException("An error occurred while transforming Json data", Some(context), e))
case Right(v) =>
val chunkAcc1 = fromB(f(v)) match {
case Some(json) => chunkAcc ++= key.map(Token.Key(_)) ++= tokenizer.tokenize(json).toList
case None => chunkAcc
case Some(newjson) => chunkAcc ++= key.map(Token.Key(_)) ++= tokenizer.tokenize(newjson).toList
case None => chunkAcc
}
Pull.pure(Some((chunk, idx, rest, chunkAcc1)))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ private[render] class StreamPrinter[F[_], Event](width: Int, indentSize: Int)(im
groups.uncons match {
case Some(((_, _, buffer), groups)) =>
Pull.output(Chunk.chain(buffer.prepend(Annotated.GroupBegin(Position.TooFar)))) >> (groups.uncons match {
case Some(((hpl, indent, _), _)) => check(hpl, indent, groups, ghpl) // check inner groups recursively
case None => Pull.pure(emptyGroups)
case Some(((newhpl, newindent, _), _)) =>
check(newhpl, newindent, groups, ghpl) // check inner groups recursively
case None => Pull.pure(emptyGroups)
})
case None =>
Pull.pure(emptyGroups) // should never happen
Expand Down Expand Up @@ -140,11 +141,11 @@ private[render] class StreamPrinter[F[_], Event](width: Int, indentSize: Int)(im
// closing unknown group, just ignore it
annotate(chunk, idx + 1, rest, pos, aligns, hpl, indent, groups)

case Some(((hpl, indent, group), groups)) =>
case Some(((newhpl, newindent, group), groups)) =>
// closing a group, pop it from the buffer dequeue, and continue
pop(groups, group.prepend(Annotated.GroupBegin(Position.Small(pos))).append(Annotated.GroupEnd(pos)))
.flatMap { groups =>
annotate(chunk, idx + 1, rest, pos, aligns, hpl, indent, groups)
annotate(chunk, idx + 1, rest, pos, aligns, newhpl, newindent, groups)
}

}
Expand Down

0 comments on commit 4bc4424

Please sign in to comment.