-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Print evaluator type and values of free variable of assertion failure predicate #1084
base: scala-2
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I was missing that (similar) feature from leon-web :)
@@ -8,9 +8,15 @@ import inox.evaluators.DeterministicEvaluator | |||
object optCodeGen extends inox.FlagOptionDef("codegen", false) | |||
|
|||
object Evaluator { | |||
val RecursiveEvaluatorName: String = "default recursive evaluator" | |||
val CodeGenEvaluatorName: String = "codegen evaluator" | |||
var kind: String = RecursiveEvaluatorName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we include the names into the evaluators instead of using the global variable kind
? I'm afraid this requires changing Inox though to add a name field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I did not want to chage Inox this time. Maybe later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of storing this in a global var, you could also compute the evaluator name to output inside the EvaluatorComponent
based on ctx.options.findOptionOrDefault(optCodeGen)
(especially since the property isn't really global).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like checking the option since it's not telling me what the evaluator actually is, but what it should have been set to and there is complex initialization logic that determines that. Unfortunately I cannot use reflection and print dynamic class name e.g.with .getClass.getSimpleName()
because somewhere in the code an anonymous class is created and the actual class name is lost.
Another question: how do I make --check-models
benefit from this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reflection should work, I think there's something like getClass.getSimpleName
which isn't too mangled.
Model checking currently takes place in Inox. The easiest way to get it to benefit from the new behavior would be to always disable optCheckModels
in Inox (like here) and check models inside Stainless. The logic on the Inox side is here. Model checking in Stainless could actually be more powerful because we have access to the type checker, but you might need to be careful about running into loops.
val msg = (err match { | ||
case Some(m) => m.toString + ": " | ||
case None => "" | ||
}) + pred.toString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally use asString
instead of toString
, so that printing respects options such as --print-ids
.
reporter.info("Relevant variables at assertion failure point:") | ||
val m = rctx.mappings | ||
val fvs = exprOps.variablesOf(pred) | ||
val fvDump: String = fvs.map(v => v.id.toString + " -> " + m.get(v.toVal).getOrElse("?").toString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toString
here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced toString with asString in two places.
Currently
--eval
does not helpfully show the bindings of variables when we encounter assertion failure. This PR makes a small change to RecursiveEvaluator to show the values of free variables of assertion failing predicate. It also displays the type of evaluator (recursive or codegen) when evaluating each function.Given this input:
the output with
--eval --no-colors
is: