diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 6933ae7da..db035f793 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -20,3 +20,6 @@ e93fe9bcf5ff0c314ca676bf9f3b9c8148574786 # Scala Steward: Reformat with scalafmt 3.7.17 7829f68c27c622dee3a8d1329d82a139f183d0c1 + +# Scala Steward: Reformat with scalafmt 3.9.7 +3c8e11c5f9f0bcfab9f7f7502578ba90c41c4bfb diff --git a/.scalafmt.conf b/.scalafmt.conf index 7b7afb96e..9d844f967 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version=3.7.17 +version=3.9.7 runner.dialect = Scala213Source3 fileOverride { "glob:**/scala-3/**" { diff --git a/core/src/main/scala-3/spire/syntax/macros/literalMacros.scala b/core/src/main/scala-3/spire/syntax/macros/literalMacros.scala index dc71f9ea2..4db5ed193 100644 --- a/core/src/main/scala-3/spire/syntax/macros/literalMacros.scala +++ b/core/src/main/scala-3/spire/syntax/macros/literalMacros.scala @@ -34,7 +34,7 @@ def byte(digits: Expr[StringContext])(using Quotes): Expr[Byte] = parseNumber(digits.valueOrAbort.parts, BigInt(-128), BigInt(255)) match case Right(a) => Expr(a.toByte) - case Left(b) => + case Left(b) => report.error(b) '{ 0.toByte } @@ -43,7 +43,7 @@ def short(digits: Expr[StringContext])(using Quotes): Expr[Short] = parseNumber(digits.valueOrAbort.parts, BigInt(-32768), BigInt(65535)) match case Right(a) => Expr(a.toShort) - case Left(b) => + case Left(b) => report.error(b) '{ 0.toShort } @@ -52,7 +52,7 @@ def ubyte(digits: Expr[StringContext])(using Quotes): Expr[UByte] = parseNumber(digits.valueOrAbort.parts, BigInt(0), BigInt(255)) match case Right(a) => '{ UByte(${ Expr(a.toByte) }) } - case Left(b) => + case Left(b) => report.error(b) '{ UByte(0) } @@ -61,7 +61,7 @@ def ushort(digits: Expr[StringContext])(using Quotes): Expr[UShort] = parseNumber(digits.valueOrAbort.parts, BigInt(0), BigInt(65535)) match case Right(a) => '{ UShort(${ Expr(a.toShort) }) } - case Left(b) => + case Left(b) => report.error(b) '{ UShort(0) } @@ -70,7 +70,7 @@ def uint(digits: Expr[StringContext])(using Quotes): Expr[UInt] = parseNumber(digits.valueOrAbort.parts, BigInt(0), BigInt(4294967295L)) match case Right(a) => '{ UInt(${ Expr(a.toInt) }) } - case Left(b) => + case Left(b) => report.error(b) '{ UInt(0) } @@ -79,7 +79,7 @@ def ulong(digits: Expr[StringContext])(using Quotes): Expr[ULong] = parseNumber(digits.valueOrAbort.parts, BigInt(0), BigInt("18446744073709551615")) match case Right(a) => '{ ULong(${ Expr(a.toLong) }) } - case Left(b) => + case Left(b) => report.error(b) '{ ULong(0) } diff --git a/core/src/main/scala/spire/math/Algebraic.scala b/core/src/main/scala/spire/math/Algebraic.scala index 568f18125..618f234d9 100644 --- a/core/src/main/scala/spire/math/Algebraic.scala +++ b/core/src/main/scala/spire/math/Algebraic.scala @@ -169,7 +169,7 @@ final class Algebraic private (val expr: Algebraic.Expr) case (that: SafeLong) => isWhole && that == this case (that: Complex[_]) => that == this case (that: Quaternion[_]) => that == this - case (that: BigDecimal) => + case (that: BigDecimal) => try { toBigDecimal(that.mc) == that } catch { @@ -421,10 +421,10 @@ final class Algebraic private (val expr: Algebraic.Expr) import Expr._ def eval(e: Expr): A = e match { - case ConstantLong(n) => conv.fromLong(n) - case ConstantDouble(n) => conv.fromDouble(n) - case ConstantBigDecimal(n) => conv.fromBigDecimal(n) - case ConstantRational(n) => conv.fromRational(n) + case ConstantLong(n) => conv.fromLong(n) + case ConstantDouble(n) => conv.fromDouble(n) + case ConstantBigDecimal(n) => conv.fromBigDecimal(n) + case ConstantRational(n) => conv.fromRational(n) case ConstantRoot(poly, i, _, _) => RootFinder[A].findRoots(poly.map(conv.fromBigInt)).get(i) case Neg(n) => -eval(n) @@ -1453,10 +1453,10 @@ object Algebraic extends AlgebraicInstances { } def apply(expr: Algebraic.Expr): Bound = expr match { - case ConstantLong(n) => integer(n) - case ConstantDouble(n) => rational(n) - case ConstantBigDecimal(n) => rational(n) - case ConstantRational(n) => rational(n) + case ConstantLong(n) => integer(n) + case ConstantDouble(n) => rational(n) + case ConstantBigDecimal(n) => rational(n) + case ConstantRational(n) => rational(n) case root @ ConstantRoot(poly, _, _, _) => Bound(root.lead.bitLength + 1, Roots.upperBound(poly)) case Neg(sub) => sub.getBound(this) diff --git a/core/src/main/scala/spire/math/Complex.scala b/core/src/main/scala/spire/math/Complex.scala index ffa3302b5..356906703 100644 --- a/core/src/main/scala/spire/math/Complex.scala +++ b/core/src/main/scala/spire/math/Complex.scala @@ -352,7 +352,7 @@ final case class Complex[@sp(Float, Double) T](real: T, imag: T) // not typesafe, so this is the best we can do :( override def equals(that: Any): Boolean = that match { - case that: Complex[_] => this === that + case that: Complex[_] => this === that case that: Quaternion[_] => real == that.r && imag == that.i && anyIsZero(that.j) && anyIsZero(that.k) case that => diff --git a/core/src/main/scala/spire/math/Interval.scala b/core/src/main/scala/spire/math/Interval.scala index 3c0c52830..15c829dc5 100644 --- a/core/src/main/scala/spire/math/Interval.scala +++ b/core/src/main/scala/spire/math/Interval.scala @@ -187,8 +187,8 @@ sealed abstract class Interval[A] extends Serializable { lhs => // Does this interval contains any points at or above t ? def hasAtOrAbove(t: A)(implicit o: Order[A]): Boolean = this match { - case _: Empty[_] => false - case Point(p) => p >= t + case _: Empty[_] => false + case Point(p) => p >= t case Below(upper, flags) => upper > t || isClosedUpper(flags) && upper === t case Bounded(lower, upper, flags) => @@ -199,8 +199,8 @@ sealed abstract class Interval[A] extends Serializable { lhs => // Does this interval contains any points at or below t ? def hasAtOrBelow(t: A)(implicit o: Order[A]): Boolean = this match { - case _: Empty[_] => false - case Point(p) => p <= t + case _: Empty[_] => false + case Point(p) => p <= t case Above(lower, flags) => lower < t || isClosedLower(flags) && lower === t case Bounded(lower, upper, flags) => @@ -890,44 +890,41 @@ object Interval { * This method assumes that lower < upper to avoid comparisons. * * - When one of the arguments is Unbound, the result will be All, Above(x, _), or Below(y, _). - * * - When both arguments are Open/Closed (e.g. Open(x), Open(y)), then x < y and the result will be a Bounded * interval. - * * - If both arguments are EmptyBound, the result is Empty. - * * - Any other arguments are invalid. * * This method cannot construct Point intervals. */ private[spire] def fromOrderedBounds[A: Order](lower: Bound[A], upper: Bound[A]): Interval[A] = (lower, upper) match { - case (EmptyBound(), EmptyBound()) => empty - case (Closed(x), Closed(y)) => Bounded(x, y, closedLowerFlags | closedUpperFlags) - case (Open(x), Open(y)) => Bounded(x, y, openLowerFlags | openUpperFlags) - case (Unbound(), Open(y)) => below(y) - case (Open(x), Unbound()) => above(x) - case (Unbound(), Closed(y)) => atOrBelow(y) - case (Closed(x), Unbound()) => atOrAbove(x) - case (Closed(x), Open(y)) => Bounded(x, y, closedLowerFlags | openUpperFlags) - case (Open(x), Closed(y)) => Bounded(x, y, openLowerFlags | closedUpperFlags) - case (Unbound(), Unbound()) => all + case (EmptyBound(), EmptyBound()) => empty + case (Closed(x), Closed(y)) => Bounded(x, y, closedLowerFlags | closedUpperFlags) + case (Open(x), Open(y)) => Bounded(x, y, openLowerFlags | openUpperFlags) + case (Unbound(), Open(y)) => below(y) + case (Open(x), Unbound()) => above(x) + case (Unbound(), Closed(y)) => atOrBelow(y) + case (Closed(x), Unbound()) => atOrAbove(x) + case (Closed(x), Open(y)) => Bounded(x, y, closedLowerFlags | openUpperFlags) + case (Open(x), Closed(y)) => Bounded(x, y, openLowerFlags | closedUpperFlags) + case (Unbound(), Unbound()) => all case (EmptyBound(), _) | (_, EmptyBound()) => throw new IllegalArgumentException("invalid empty bound") } def fromBounds[A: Order](lower: Bound[A], upper: Bound[A]): Interval[A] = (lower, upper) match { - case (EmptyBound(), EmptyBound()) => empty - case (Closed(x), Closed(y)) => closed(x, y) - case (Open(x), Open(y)) => open(x, y) - case (Unbound(), Open(y)) => below(y) - case (Open(x), Unbound()) => above(x) - case (Unbound(), Closed(y)) => atOrBelow(y) - case (Closed(x), Unbound()) => atOrAbove(x) - case (Closed(x), Open(y)) => openUpper(x, y) - case (Open(x), Closed(y)) => openLower(x, y) - case (Unbound(), Unbound()) => all + case (EmptyBound(), EmptyBound()) => empty + case (Closed(x), Closed(y)) => closed(x, y) + case (Open(x), Open(y)) => open(x, y) + case (Unbound(), Open(y)) => below(y) + case (Open(x), Unbound()) => above(x) + case (Unbound(), Closed(y)) => atOrBelow(y) + case (Closed(x), Unbound()) => atOrAbove(x) + case (Closed(x), Open(y)) => openUpper(x, y) + case (Open(x), Closed(y)) => openLower(x, y) + case (Unbound(), Unbound()) => all case (EmptyBound(), _) | (_, EmptyBound()) => throw new IllegalArgumentException("invalid empty bound") } @@ -955,8 +952,8 @@ object Interval { def apply(s: String): Interval[Rational] = s match { - case NullRe() => Interval.empty[Rational] - case SingleRe(x) => Interval.point(Rational(x)) + case NullRe() => Interval.empty[Rational] + case SingleRe(x) => Interval.point(Rational(x)) case PairRe(left, x, y, right) => (left, x, y, right) match { case ("(", "-∞", "∞", ")") => Interval.all[Rational] diff --git a/core/src/main/scala/spire/math/Natural.scala b/core/src/main/scala/spire/math/Natural.scala index 79fa512d9..2d1ea1ab7 100644 --- a/core/src/main/scala/spire/math/Natural.scala +++ b/core/src/main/scala/spire/math/Natural.scala @@ -357,10 +357,10 @@ sealed abstract class Natural extends ScalaNumber with ScalaNumericConversions w } def *(rhs: Natural): Natural = lhs match { - case End(ld) => rhs * ld + case End(ld) => rhs * ld case Digit(ld, ltail) => rhs match { - case End(rd) => lhs * rd + case End(rd) => lhs * rd case Digit(rd, rtail) => Digit(UInt(0), Digit(UInt(0), ltail * rtail)) + Digit(UInt(0), ltail * rd) + @@ -402,7 +402,7 @@ sealed abstract class Natural extends ScalaNumber with ScalaNumericConversions w case Digit(ld, ltail) => rhs.compare(UInt(1)) match { case -1 => throw new IllegalArgumentException("/ by zero") - case 0 => + case 0 => lhs case 1 => val p = rhs.powerOfTwo @@ -428,7 +428,7 @@ sealed abstract class Natural extends ScalaNumber with ScalaNumericConversions w rhs.compare(UInt(1)) match { case -1 => throw new IllegalArgumentException("/ by zero") case 0 => End(UInt(0)) - case 1 => + case 1 => val p = rhs.powerOfTwo if (p >= 0) lhs & ((Natural(1) << p) - UInt(1)) @@ -451,7 +451,7 @@ sealed abstract class Natural extends ScalaNumber with ScalaNumericConversions w rhs.compare(UInt(1)) match { case -1 => throw new IllegalArgumentException("/ by zero") case 0 => (lhs, Natural(0)) - case 1 => + case 1 => val p = rhs.powerOfTwo if (p >= 0) { val mask = (Natural(1) << p) - UInt(1) diff --git a/core/src/main/scala/spire/math/Polynomial.scala b/core/src/main/scala/spire/math/Polynomial.scala index e27c981e0..dae536a8c 100644 --- a/core/src/main/scala/spire/math/Polynomial.scala +++ b/core/src/main/scala/spire/math/Polynomial.scala @@ -566,7 +566,7 @@ trait PolynomialOverField[@sp(Double) C] override def equotmod(x: Polynomial[C], y: Polynomial[C]): (Polynomial[C], Polynomial[C]) = { require(!y.isZero, "Can't divide by polynomial of zero!") (x: @unchecked) match { - case xd: poly.PolyDense[C] => poly.PolyDense.quotmodDense(xd, y) + case xd: poly.PolyDense[C] => poly.PolyDense.quotmodDense(xd, y) case xs: poly.PolySparse[C] => val ys = (y: @unchecked) match { case yd: poly.PolyDense[C] => poly.PolySparse.dense2sparse(yd) diff --git a/core/src/main/scala/spire/math/Quaternion.scala b/core/src/main/scala/spire/math/Quaternion.scala index 636893c4a..a250ae716 100644 --- a/core/src/main/scala/spire/math/Quaternion.scala +++ b/core/src/main/scala/spire/math/Quaternion.scala @@ -151,7 +151,7 @@ final case class Quaternion[@sp(Float, Double) A](r: A, i: A, j: A, k: A) // not typesafe, so this is the best we can do :( override def equals(that: Any): Boolean = that match { case that: Quaternion[_] => this === that - case that: Complex[_] => + case that: Complex[_] => r == that.real && i == that.imag && anyIsZero(j) && anyIsZero(k) case that => sillyIsReal && r == that diff --git a/core/src/main/scala/spire/math/Rational.scala b/core/src/main/scala/spire/math/Rational.scala index 0634ea28f..1c5f82626 100644 --- a/core/src/main/scala/spire/math/Rational.scala +++ b/core/src/main/scala/spire/math/Rational.scala @@ -273,9 +273,9 @@ sealed abstract class Rational extends ScalaNumber with ScalaNumericConversions } override def equals(that: Any): Boolean = that match { - case that: Real => this == that.toRational - case that: Algebraic => that == this - case that: BigInt => isWhole && toBigInt == that + case that: Real => this == that.toRational + case that: Algebraic => that == this + case that: BigInt => isWhole && toBigInt == that case that: BigDecimal => try { toBigDecimal(that.mc) == that } catch { case ae: ArithmeticException => false } @@ -413,7 +413,7 @@ object Rational extends RationalInstances { def apply(r: String): Rational = r match { case RationalString(n, d) => Rational(SafeLong(n), SafeLong(d)) case IntegerString(n) => Rational(SafeLong(n)) - case s => + case s => try { Rational(BigDecimal(s)) } catch { @@ -786,7 +786,7 @@ object Rational extends RationalInstances { def +(r: Rational): Rational = r match { case r: LongRational => r + this - case r: BigRational => + case r: BigRational => val dgcd: SafeLong = d.gcd(r.d) if (dgcd.isOne) { Rational(r.d * n + r.n * d, r.d * d) @@ -804,7 +804,7 @@ object Rational extends RationalInstances { def -(r: Rational): Rational = r match { case r: LongRational => (-r) + this - case r: BigRational => + case r: BigRational => val dgcd: SafeLong = d.gcd(r.d) if (dgcd.isOne) { Rational(r.d * n - r.n * d, r.d * d) @@ -822,7 +822,7 @@ object Rational extends RationalInstances { def *(r: Rational): Rational = r match { case r: LongRational => r * this - case r: BigRational => + case r: BigRational => val a = n.gcd(r.d) val b = d.gcd(r.n) Rational((n / a) * (r.n / b), (d / b) * (r.d / a)) @@ -830,7 +830,7 @@ object Rational extends RationalInstances { def /(r: Rational): Rational = r match { case r: LongRational => r.inverse * this - case r: BigRational => + case r: BigRational => val a = n.gcd(r.n) val b = d.gcd(r.d) val num = (n / a) * (r.d / b) diff --git a/core/src/main/scala/spire/math/Real.scala b/core/src/main/scala/spire/math/Real.scala index 1240cf130..1ad6ecf83 100644 --- a/core/src/main/scala/spire/math/Real.scala +++ b/core/src/main/scala/spire/math/Real.scala @@ -120,7 +120,7 @@ sealed trait Real extends ScalaNumber with ScalaNumericConversions { x => this match { case Exact(n) => Exact(n.reciprocal) - case _ => + case _ => Real { p => val s = findNonzero(0) roundUp(Rational(SafeLong.two.pow(2 * p + 2 * s + 2), x(p + 2 * s + 2))) @@ -143,7 +143,7 @@ sealed trait Real extends ScalaNumber with ScalaNumericConversions { x => case (_, Exact(Rational.zero)) => Real.zero case (Exact(Rational.one), _) => y case (_, Exact(Rational.one)) => x - case _ => + case _ => Real { p => val x0 = x(0).abs + 2 val y0 = y(0).abs + 2 @@ -183,7 +183,7 @@ sealed trait Real extends ScalaNumber with ScalaNumericConversions { x => def tmod(y: Real): Real = (x, y) match { case (Exact(nx), Exact(ny)) => Exact(nx.tmod(ny)) - case _ => + case _ => Real { p => val d = x / y val s = d(2) @@ -194,7 +194,7 @@ sealed trait Real extends ScalaNumber with ScalaNumericConversions { x => def tquot(y: Real): Real = (x, y) match { case (Exact(nx), Exact(ny)) => Exact(nx.tquot(ny)) - case _ => + case _ => Real { p => val d = x / y val s = d(2) @@ -223,7 +223,7 @@ sealed trait Real extends ScalaNumber with ScalaNumericConversions { x => def ceil: Real = x match { case Exact(n) => Exact(n.ceil) - case _ => + case _ => Real { p => val n = x(p) val t = SafeLong.two.pow(p) @@ -236,7 +236,7 @@ sealed trait Real extends ScalaNumber with ScalaNumericConversions { x => def floor: Real = x match { case Exact(n) => Exact(n.floor) - case _ => + case _ => Real { p => val n = x(p) val t = SafeLong.two.pow(p) @@ -247,7 +247,7 @@ sealed trait Real extends ScalaNumber with ScalaNumericConversions { x => def round: Real = x match { case Exact(n) => Exact(n.round) - case _ => + case _ => Real { p => val n = x(p) val t = SafeLong.two.pow(p) @@ -282,7 +282,7 @@ sealed trait Real extends ScalaNumber with ScalaNumericConversions { x => // a bit hand-wavy def fpow(y: Real): Real = y match { case Exact(n) => x.fpow(n) - case _ => + case _ => Real { p => x.fpow(Rational(y(p), SafeLong.two.pow(p)))(p) } @@ -503,8 +503,8 @@ object Real extends RealInstances { def accumulate(total: SafeLong, xs: LazyList[SafeLong], cs: LazyList[Rational]): SafeLong = { ((xs, cs): @unchecked) match { - case (_, Seq()) => total - case (Seq(), _) => sys.error("nooooo") + case (_, Seq()) => total + case (Seq(), _) => sys.error("nooooo") case (x #:: xs, c #:: cs) => val t = roundUp(c * Rational(x)) if (t == 0) total else accumulate(total + t, xs, cs) @@ -515,8 +515,8 @@ object Real extends RealInstances { def accumulate(total: SafeLong, xs: Stream[SafeLong], cs: Stream[Rational]): SafeLong = { import scala.#:: ((xs, cs): @unchecked) match { - case (_, Stream.Empty) => total - case (Stream.Empty, _) => sys.error("nooooo") + case (_, Stream.Empty) => total + case (Stream.Empty, _) => sys.error("nooooo") case (x #:: xs, c #:: cs) => val t = roundUp(c * Rational(x)) if (t == 0) total else accumulate(total + t, xs, cs) diff --git a/core/src/main/scala/spire/math/interval/Overlap.scala b/core/src/main/scala/spire/math/interval/Overlap.scala index 5e8351115..a1941a59a 100644 --- a/core/src/main/scala/spire/math/interval/Overlap.scala +++ b/core/src/main/scala/spire/math/interval/Overlap.scala @@ -78,7 +78,7 @@ object Overlap { // only possible cases left are disjoint or partial overlap case i: Bounded[A] => lessAndOverlaps(i.lowerBound) case i: Point[A] => lessAndOverlaps(i.lowerBound) - case Empty() => + case Empty() => if (Interval.fromBounds(lhs.lowerBound, rhs.upperBound).isEmpty) Disjoint(rhs, lhs) else Disjoint(lhs, rhs) case _ => throw new Exception("impossible") diff --git a/core/src/main/scala/spire/math/prime/SieveSegment.scala b/core/src/main/scala/spire/math/prime/SieveSegment.scala index 4372e2476..2f13109f4 100644 --- a/core/src/main/scala/spire/math/prime/SieveSegment.scala +++ b/core/src/main/scala/spire/math/prime/SieveSegment.scala @@ -178,7 +178,8 @@ case class SieveSegment(start: SafeLong, primes: BitSet, cutoff: SafeLong) { while (k < lim) { k += pp; primes -= k } m = k.toLong + pp } - if (p < 7) {} else if (m - primes.length < primes.length) { + if (p < 7) {} + else if (m - primes.length < primes.length) { buf += FastFactor(p, SafeLong(m)) } else if (cutoff > p) { slowq += Factor(SafeLong(p), SafeLong(m)) diff --git a/core/src/main/scala/spire/random/rng/MersenneTwister32.scala b/core/src/main/scala/spire/random/rng/MersenneTwister32.scala index 11effa611..cec07654b 100644 --- a/core/src/main/scala/spire/random/rng/MersenneTwister32.scala +++ b/core/src/main/scala/spire/random/rng/MersenneTwister32.scala @@ -41,7 +41,8 @@ import java.util.Arrays * @author * Dušan Kysel */ -final class MersenneTwister32 protected[random] (mt: Array[Int], mti0: Int = 625) extends IntBasedGenerator { // N + 1 == 625 +final class MersenneTwister32 protected[random] (mt: Array[Int], mti0: Int = 625) + extends IntBasedGenerator { // N + 1 == 625 import MersenneTwister32.{mag01, BYTES, LowerMask, M, M_1, M_N, N, N_1, N_M, UpperMask} diff --git a/core/src/main/scala/spire/random/rng/MersenneTwister64.scala b/core/src/main/scala/spire/random/rng/MersenneTwister64.scala index c1f820a0b..9cf44b4b6 100644 --- a/core/src/main/scala/spire/random/rng/MersenneTwister64.scala +++ b/core/src/main/scala/spire/random/rng/MersenneTwister64.scala @@ -41,7 +41,8 @@ import java.util.Arrays * @author * Dušan Kysel */ -final class MersenneTwister64 protected[random] (mt: Array[Long], mti0: Int = 313) extends LongBasedGenerator { // N + 1 = 313 +final class MersenneTwister64 protected[random] (mt: Array[Long], mti0: Int = 313) + extends LongBasedGenerator { // N + 1 = 313 import MersenneTwister64.{mag01, BYTES, LowerMask, M, M_1, M_N, N, N_1, N_M, UpperMask} diff --git a/macros/src/main/scala-2/spire/macros/Syntax.scala b/macros/src/main/scala-2/spire/macros/Syntax.scala index c765a8e46..b42f84dbd 100644 --- a/macros/src/main/scala-2/spire/macros/Syntax.scala +++ b/macros/src/main/scala-2/spire/macros/Syntax.scala @@ -287,7 +287,7 @@ object Syntax { isLiteral(step) match { case Some(k) if k > 0 => strideUpUntil(i, j, k) case Some(k) if k < 0 => strideDownUntil(i, j, -k) - case Some(k) => + case Some(k) => c.error(c.enclosingPosition, "zero stride") q"()" case None => @@ -299,7 +299,7 @@ object Syntax { isLiteral(step) match { case Some(k) if k > 0 => strideUpTo(i, j, k) case Some(k) if k < 0 => strideDownTo(i, j, -k) - case Some(k) => + case Some(k) => c.error(c.enclosingPosition, "zero stride") q"()" case None => diff --git a/tests/shared/src/test/scala/spire/math/SortingSuite.scala b/tests/shared/src/test/scala/spire/math/SortingSuite.scala index ac56085d2..43ea4962e 100644 --- a/tests/shared/src/test/scala/spire/math/SortingSuite.scala +++ b/tests/shared/src/test/scala/spire/math/SortingSuite.scala @@ -175,9 +175,10 @@ class SortingSuite extends munit.FunSuite { val pivotValue = 7 val expectedAfterPartition = Array(5, 2, 1, 7, 8, 11, 9) - matchAgainstExpected[Int](QuickSort.partition(_, 2, 9, 5), - Array(6, -1) ++ leftSegment ++ Array(pivotValue) ++ rightSegment ++ Array(2, 10), - Array(6, -1) ++ expectedAfterPartition ++ Array(2, 10) + matchAgainstExpected[Int]( + QuickSort.partition(_, 2, 9, 5), + Array(6, -1) ++ leftSegment ++ Array(pivotValue) ++ rightSegment ++ Array(2, 10), + Array(6, -1) ++ expectedAfterPartition ++ Array(2, 10) ) }