summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2021-10-01 16:38:15 -0500
committerGitHub <noreply@github.com>2021-10-01 21:38:15 +0000
commit8210a5ebefd4cc0779d7968e891db5bc63dba545 (patch)
tree2688bef07728a5928c2329a7ecaa56fbe4a4400d
parent8848b31ec753ba87522fb6e5d76163f2979e73a2 (diff)
Fix ascription check for return types on ordinary functions (#7290)
Fixes #7274.
-rw-r--r--src/parser/parser.cpp16
-rw-r--r--test/regress/CMakeLists.txt1
-rw-r--r--test/regress/regress0/parser/issue7274.smt27
3 files changed, 19 insertions, 5 deletions
diff --git a/src/parser/parser.cpp b/src/parser/parser.cpp
index 39b38be30..84c0bd17c 100644
--- a/src/parser/parser.cpp
+++ b/src/parser/parser.cpp
@@ -598,13 +598,19 @@ api::Term Parser::applyTypeAscription(api::Term t, api::Sort s)
}
return t;
}
- // otherwise, nothing to do
- // check that the type is correct
- if (t.getSort() != s)
+ // Otherwise, check that the type is correct. Type ascriptions in SMT-LIB 2.6
+ // referred to the range of function sorts. Note that this is only a check
+ // and does not impact the returned term.
+ api::Sort checkSort = t.getSort();
+ if (checkSort.isFunction())
+ {
+ checkSort = checkSort.getFunctionCodomainSort();
+ }
+ if (checkSort != s)
{
std::stringstream ss;
- ss << "Type ascription not satisfied, term " << t << " expected sort " << s
- << " but has sort " << t.getSort();
+ ss << "Type ascription not satisfied, term " << t
+ << " expected (codomain) sort " << s << " but has sort " << t.getSort();
parseError(ss.str());
}
return t;
diff --git a/test/regress/CMakeLists.txt b/test/regress/CMakeLists.txt
index 3bfe356fa..768fe852f 100644
--- a/test/regress/CMakeLists.txt
+++ b/test/regress/CMakeLists.txt
@@ -779,6 +779,7 @@ set(regress_0_tests
regress0/parser/force_logic_set_logic.smt2
regress0/parser/force_logic_success.smt2
regress0/parser/issue5163.smt2
+ regress0/parser/issue7274.smt2
regress0/parser/linear_arithmetic_err1.smt2
regress0/parser/linear_arithmetic_err2.smt2
regress0/parser/linear_arithmetic_err3.smt2
diff --git a/test/regress/regress0/parser/issue7274.smt2 b/test/regress/regress0/parser/issue7274.smt2
new file mode 100644
index 000000000..c7a38d078
--- /dev/null
+++ b/test/regress/regress0/parser/issue7274.smt2
@@ -0,0 +1,7 @@
+(set-logic ALL)
+(set-info :status sat)
+(declare-fun f (Int) Int)
+(declare-fun g1 (Int) Int)
+(declare-fun x () Int)
+(assert (= ((as f Int) x) (g1 x)))
+(check-sat)
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback