Skip to content

Commit 360cc44

Browse files
authored
Merge branch 'master' into meilers_pretty_printer_linebreaks
2 parents ae365ef + 5f9404e commit 360cc44

32 files changed

Lines changed: 261 additions & 95 deletions

build.sbt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ ThisBuild / scalacOptions ++= Seq(
1414
"-unchecked", // Warn on generated code assumptions
1515
"-feature", // Warn on features that requires explicit import
1616
"-Wunused", // Warn on unused imports
17-
"-Ypatmat-exhaust-depth", "40" // Increase depth of pattern matching analysis
17+
"-Ypatmat-exhaust-depth", "40", // Increase depth of pattern matching analysis
18+
// "-Xfatal-warnings", // Treat Warnings as errors to guarantee code quality in future changes
1819
)
1920

2021
// Enforce UTF-8, instead of relying on properly set locales

src/main/scala/viper/silver/ast/Ast.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,9 @@ trait Info {
358358
case _ => Seq.empty
359359
}
360360

361-
def removeUniqueInfo[T <: Info]: Info = this match {
361+
def removeUniqueInfo[T <: Info : ClassTag]: Info = this match {
362362
case ConsInfo(a, b) => MakeInfoPair(a.removeUniqueInfo[T], b.removeUniqueInfo[T])
363-
case t: T => NoInfo
363+
case _: T => NoInfo
364364
case info => info
365365
}
366366
}

src/main/scala/viper/silver/ast/Expression.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ case class DomainFuncApp(funcname: String, args: Seq[Exp], typVarMap: Map[TypeVa
396396
//Strangely, the copy method is not a member of the DomainFuncApp case class,
397397
//therefore, We need this method that does the copying manually
398398
def copy(funcname: String = this.funcname, args: Seq[Exp] = this.args, typVarMap: Map[TypeVar, Type] = this.typVarMap): (Position, Info, Type, String, ErrorTrafo) => DomainFuncApp ={
399-
DomainFuncApp(this.funcname,args,typVarMap)
399+
DomainFuncApp(funcname,args,typVarMap)
400400
}
401401
}
402402
object DomainFuncApp {
@@ -410,7 +410,7 @@ case class BackendFuncApp(backendFunc: BackendFunc, args: Seq[Exp])
410410
(val pos: Position = NoPosition, val info: Info = NoInfo, val errT: ErrorTrafo = NoTrafos)
411411
extends AbstractDomainFuncApp {
412412
override lazy val check : Seq[ConsistencyError] = args.flatMap(Consistency.checkPure)
413-
override def func = (p: Program) => backendFunc
413+
override def func = (_: Program) => backendFunc
414414
def funcname = backendFunc.name
415415
override def typ = backendFunc.typ
416416
}
@@ -565,6 +565,7 @@ case class Forall(variables: Seq[LocalVarDecl], triggers: Seq[Trigger], exp: Exp
565565
//require(isValid, s"Invalid quantifier: { $this } .")
566566
override lazy val check : Seq[ConsistencyError] =
567567
(if(!(exp isSubtype Bool)) Seq(ConsistencyError(s"Body of universal quantifier must be of Bool type, but found ${exp.typ}", exp.pos)) else Seq()) ++
568+
(if (variables.isEmpty) Seq(ConsistencyError("Quantifier must have at least one quantified variable.", pos)) else Seq()) ++
568569
Consistency.checkAllVarsMentionedInTriggers(variables, triggers) ++
569570
checkNoNestedQuantsForQuantPermissions ++
570571
checkQuantifiedPermission
@@ -631,7 +632,8 @@ case class Forall(variables: Seq[LocalVarDecl], triggers: Seq[Trigger], exp: Exp
631632
/** Existential quantification. */
632633
case class Exists(variables: Seq[LocalVarDecl], triggers: Seq[Trigger], exp: Exp)(val pos: Position = NoPosition, val info: Info = NoInfo, val errT: ErrorTrafo = NoTrafos) extends QuantifiedExp {
633634
override lazy val check : Seq[ConsistencyError] = Consistency.checkPure(exp) ++
634-
(if(!(exp isSubtype Bool)) Seq(ConsistencyError(s"Body of existential quantifier must be of Bool type, but found ${exp.typ}", exp.pos)) else Seq())
635+
(if(!(exp isSubtype Bool)) Seq(ConsistencyError(s"Body of existential quantifier must be of Bool type, but found ${exp.typ}", exp.pos)) else Seq()) ++
636+
(if (variables.isEmpty) Seq(ConsistencyError("Quantifier must have at least one quantified variable.", pos)) else Seq())
635637

636638
/** Returns an identical forall quantification that has some automatically generated triggers
637639
* if necessary and possible.

src/main/scala/viper/silver/ast/utility/Consistency.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ package viper.silver.ast.utility
88

99
import viper.silver.ast._
1010
import viper.silver.ast.utility.rewriter.Traverse
11-
import viper.silver.parser.{FastParser, FastParserCompanion}
11+
import viper.silver.parser.FastParserCompanion
1212
import viper.silver.verifier.ConsistencyError
1313
import viper.silver.{FastMessage, FastMessaging}
1414

src/main/scala/viper/silver/ast/utility/Functions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ object Functions {
2525
def allSubexpressionsIncludingUnfoldings(program: Program)(func: Function): Seq[Exp] = {
2626
var visitedPredicates = Set[String]()
2727
var subexpressions = allSubexpressions(func)
28-
var unfoldings = new ListBuffer[Unfolding]
28+
val unfoldings = new ListBuffer[Unfolding]
2929
unfoldings ++= (subexpressions map (e => e.deepCollect{case u@Unfolding(_, _) => u})).flatten
3030
var i = 0
3131
while (i < unfoldings.length){

src/main/scala/viper/silver/ast/utility/ViperStrategy.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,13 @@ object ViperStrategy {
179179
Trafos(
180180
newMetaData._3.eTransformations,
181181
newMetaData._3.rTransformations,
182-
newMetaData._3.nTransformations.orElse(Some(n.asInstanceOf[ErrorNode])))
182+
newMetaData._3.nTransformations.orElse(Some(n)))
183183
} else {
184184
/* Keep already attached transformations (if any) */
185185
newMetaData._3
186186
}
187187
}
188-
now
188+
now.withMeta(newMetaData._1, newMetaData._2, newNodeTrafo)
189189
} else {
190190
now
191191
}

src/main/scala/viper/silver/ast/utility/rewriter/Strategy.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package viper.silver.ast.utility.rewriter
88
import viper.silver.ast.utility.rewriter.Traverse.Traverse
99

10+
import scala.annotation.unused
1011
import scala.collection.mutable
1112
import scala.reflect.runtime.{universe => reflection}
1213

@@ -92,7 +93,7 @@ trait StrategyInterface[N <: Rewritable] {
9293
* rewritten.
9394
* @return Updated node that will be built into the AST
9495
*/
95-
protected def preserveMetaData(old: N, now: N, directlyRewritten: Boolean): N = now
96+
protected def preserveMetaData(@unused old: N, now: N, @unused directlyRewritten: Boolean): N = now
9697
}
9798

9899
/**

src/main/scala/viper/silver/ast/utility/rewriter/TRegex.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
package viper.silver.ast.utility.rewriter
88

9+
import scala.annotation.unused
910
import scala.reflect.runtime.{universe => reflection}
1011

1112
/*
@@ -140,10 +141,10 @@ class NMatch[N <: Rewritable : TypeTag](val pred: N => Boolean, val rewrite: Boo
140141

141142
/**
142143
* Provide information about the actions that occur if node n matches on this matcher
143-
* @param n node used for traversion
144-
* @return list of traversion infos
144+
* @param n node used for traversal
145+
* @return list of traversal infos
145146
*/
146-
def getTransitionInfo(n: Rewritable): Seq[TransitionInfo] = if (rewrite) Seq(MarkedForRewrite()) else Seq.empty[TransitionInfo]
147+
def getTransitionInfo(@unused n: Rewritable): Seq[TransitionInfo] = if (rewrite) Seq(MarkedForRewrite()) else Seq.empty[TransitionInfo]
147148

148149
}
149150

src/main/scala/viper/silver/cfg/utility/LoopDetector.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package viper.silver.cfg.utility
88

99
import java.util.concurrent.atomic.AtomicInteger
1010

11-
import viper.silver.ast.utility.ViperStrategy
1211
import viper.silver.ast.utility.rewriter.Traverse
1312
import viper.silver.ast.{Exp, If, Info, Infoed, LocalVar, MakeInfoPair, NoInfo, Seqn, Stmt}
1413
import viper.silver.cfg._

src/main/scala/viper/silver/frontend/SilFrontend.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ trait SilFrontend extends DefaultFrontend {
242242
Succ({e.initProperties(); e})
243243
}
244244
else Fail(err_list)
245-
case fail @ Parsed.Failure(_, index, extra) =>
245+
case fail @ Parsed.Failure(_, index, _) =>
246246
val msg = fail.trace().longAggregateMsg
247247
val (line, col) = fp.lineCol.getPos(index)
248248
Fail(List(ParseError(s"Expected $msg", SourcePosition(file, line, col))))

0 commit comments

Comments
 (0)