diff options
-rw-r--r-- | lib/Expr/Parser.cpp | 5 | ||||
-rw-r--r-- | test/Expr/Parser/TypeChecking.pc | 9 |
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/Expr/Parser.cpp b/lib/Expr/Parser.cpp index e059c675..c20c5d66 100644 --- a/lib/Expr/Parser.cpp +++ b/lib/Expr/Parser.cpp @@ -853,7 +853,10 @@ ExprResult ParserImpl::ParseBinaryParenExpr(const Token &Name, return ConstantExpr::alloc(0, ResTy); ref<Expr> LHS_E = LHS.get(), RHS_E = RHS.get(); - assert(LHS_E->getWidth() == RHS_E->getWidth() && "Mismatched types!"); + if (LHS_E->getWidth() != RHS_E->getWidth()) { + Error("type widths do not match in binary expression", Name); + return ConstantExpr::alloc(0, ResTy); + } switch (Kind) { case Expr::Add: return AddExpr::alloc(LHS_E, RHS_E); diff --git a/test/Expr/Parser/TypeChecking.pc b/test/Expr/Parser/TypeChecking.pc new file mode 100644 index 00000000..4633313d --- /dev/null +++ b/test/Expr/Parser/TypeChecking.pc @@ -0,0 +1,9 @@ +# RUN: not %kleaver %s 2> %t.log + + + +# RUN: grep "TypeChecking.pc:6:9: error: type widths do not match in binary expression" %t.log +(query [(Eq (ReadLSB w32 0 arr1) true)] + false) + +# RUN: grep "TypeChecking.pc: parse failure: 1 errors." %t.log |