From 267cbe382251e5f15bc7a492af21a64bbeae8fe3 Mon Sep 17 00:00:00 2001 From: ajreynol Date: Tue, 3 Dec 2024 09:37:07 -0600 Subject: [PATCH] Improve error message for type check app --- src/type_checker.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/type_checker.cpp b/src/type_checker.cpp index 881338a..2b9fd6a 100644 --- a/src/type_checker.cpp +++ b/src/type_checker.cpp @@ -447,11 +447,29 @@ Expr TypeChecker::getTypeAppInternal(std::vector& children, { if (out) { - (*out) << "Unexpected argument type " << i << " of " << Expr(hd) - << std::endl; - (*out) << " LHS " << evaluate(hdtypes[i], ctx) << ", from " - << Expr(hdtypes[i]) << std::endl; - (*out) << " RHS " << Expr(ctypes[i]) << std::endl; + if (hdtypes[i]->getKind()==Kind::QUOTE_TYPE) + { + (*out) << "Unexpected child #" << i << std::endl; + (*out) << " Term: " << Expr(children[i+1]) << std::endl; + (*out) << " Expected pattern: " << Expr(hdt); + if ((*hdtypes[i])[0]!=hdt) + { + (*out) << ", from " << Expr((*hdtypes[i])[0]); + } + (*out) << std::endl; + } + else + { + (*out) << "Unexpected type of child #" << i << std::endl; + (*out) << " Term: " << Expr(children[i+1]) << std::endl; + (*out) << " Has type: " << Expr(ctypes[i]) << std::endl; + (*out) << " Expected type: " << Expr(hdt); + if (hdtypes[i]!=hdt) + { + (*out) << ", from " << Expr(hdtypes[i]); + } + (*out) << std::endl; + } (*out) << " Context " << ctx << std::endl; } return d_null;