Fix propagate failure on on reactivated constraint. Always report a failure to avoid confusion with the trace view.

This commit is contained in:
Fedor Isakov 2018-11-14 21:22:38 +01:00
parent 087ccf4503
commit 8db1aead11
1 changed files with 11 additions and 7 deletions

View File

@ -56,13 +56,14 @@ class Controller(
throw t
}
fun reactivate(occurrence: ConstraintOccurrence) =
try {
process(occurrence, NORMAL())
}
catch (t: Throwable) {
throw t
fun reactivate(occurrence: ConstraintOccurrence) {
// FIXME propagate the processing state further up the call stack
// TODO: introduce processing state to solver API?
val state = process(occurrence, NORMAL())
if (state is FAILED) {
throw state.failure.cause
}
}
/** For tests only */
fun evaluate(occurrence: ConstraintOccurrence): StoreView {
@ -149,17 +150,20 @@ class Controller(
}
if (state is FAILED) {
trace.failure(state.failure)
if (!altIt.hasNext()) {
// last alternative
if (failureHandler != null) {
// FIXME: failure handler may replace the failure
val updatedFailure = failureHandler.handleFailure(state.failure, match.rule())
if (updatedFailure == null) {
state = state.reset()
}
}
}
if (state is FAILED) {
trace.failure(state.failure)
frameStack.reset(savedFrame)
}