From 468155bdca951f7c8c7dfca7512f2ad8b14414ed Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" Date: Thu, 6 Mar 2025 12:00:07 -0500 Subject: [PATCH 1/2] Distinguish "Bad plan description!" failures. There are 2 causes for this failure message: either the plan is missing (presumably it's ill-formatted), or the plan fails to type-check. Give different error messages for the two cases. --- applications/Validate/src/main.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/applications/Validate/src/main.cpp b/applications/Validate/src/main.cpp index 428acaf..4609836 100644 --- a/applications/Validate/src/main.cpp +++ b/applications/Validate/src/main.cpp @@ -137,7 +137,15 @@ plan *getPlan(int &argc, char *argv[], int &argcount, TypeChecker &tc, if (!the_plan || !tc.typecheckPlan(the_plan)) { failed.push_back(name); - if (Silent < 2) *report << "Bad plan description!\n"; + if (Silent < 2) { + *report << "Bad plan description!\n"; + if (!the_plan) { + *report << "Unable to read plan file.\n"; + } + else { + *report << "Plan failed to type-check\n"; + } + } if (Silent > 1) *report << "failed\n"; delete the_plan; the_plan = 0; From 1485b43c6cc0efe90347c4391cf38acfa19de73b Mon Sep 17 00:00:00 2001 From: "Robert P. Goldman" Date: Wed, 12 Mar 2025 12:37:29 -0500 Subject: [PATCH 2/2] Informative output for typecheck failure. Add a new function, `TypeChecker::planTypecheckFlaw` that returns an explanatory string identifying the step when a typechecking error occurs in plan validation. --- applications/Validate/src/main.cpp | 3 ++- libraries/VAL/include/typecheck.h | 1 + libraries/VAL/src/typecheck.cpp | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/applications/Validate/src/main.cpp b/applications/Validate/src/main.cpp index 4609836..2880e3e 100644 --- a/applications/Validate/src/main.cpp +++ b/applications/Validate/src/main.cpp @@ -1,4 +1,4 @@ -// Copyright 2019 - University of Strathclyde, King's College London and Schlumberger Ltd +// Copyright 2019-2025 - University of Strathclyde, King's College London, Schlumberger Ltd and SIFT, LLC // This source code is licensed under the BSD license found in the LICENSE file in the root directory of this source tree. #include "Plan.h" @@ -144,6 +144,7 @@ plan *getPlan(int &argc, char *argv[], int &argcount, TypeChecker &tc, } else { *report << "Plan failed to type-check\n"; + *report << tc.planTypecheckFlaw(the_plan); } } if (Silent > 1) *report << "failed\n"; diff --git a/libraries/VAL/include/typecheck.h b/libraries/VAL/include/typecheck.h index 22d61b5..1ef115b 100644 --- a/libraries/VAL/include/typecheck.h +++ b/libraries/VAL/include/typecheck.h @@ -123,6 +123,7 @@ namespace VAL { bool typecheckAction(const operator_ *act); bool typecheckProblem(); bool typecheckPlan(const plan *p); + std::string planTypecheckFlaw(const plan *p); bool typecheckGoal(const goal *g); bool typecheckProposition(const proposition *g); bool typecheckActionInstance(const plan_step *p); diff --git a/libraries/VAL/src/typecheck.cpp b/libraries/VAL/src/typecheck.cpp index 549442a..068c32c 100644 --- a/libraries/VAL/src/typecheck.cpp +++ b/libraries/VAL/src/typecheck.cpp @@ -7,6 +7,8 @@ #include "ptree.h" #include #include +#include +#include namespace VAL { @@ -708,6 +710,16 @@ namespace VAL { return p->end() == std::find_if(p->begin(), p->end(), badchecker(this)); }; + + std::string TypeChecker::planTypecheckFlaw(const plan *p) { + std::ostringstream oss; + oss << "Type error in:\n"; + oss << *(std::find_if(p->begin(), p->end(), badchecker(this))); + oss << "\n"; + return oss.str(); + }; + + vector< const_symbol * > TypeChecker::range(const var_symbol *v) { vector< const_symbol * > l; for (const_symbol_table::const_iterator i = thea->const_tab.begin();