From 62eab18833e2dc4f0a3389156c8ee2ee35775259 Mon Sep 17 00:00:00 2001 From: Anna Rift Date: Fri, 22 Nov 2024 11:52:21 -0800 Subject: [PATCH] Fix mistakes in handling of == ? - Return true from resolveFnCallSpecial if handled - Invert result for != Signed-off-by: Anna Rift --- frontend/lib/resolution/resolution-queries.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/lib/resolution/resolution-queries.cpp b/frontend/lib/resolution/resolution-queries.cpp index 6ba9b07d3523..b4f8f6428454 100644 --- a/frontend/lib/resolution/resolution-queries.cpp +++ b/frontend/lib/resolution/resolution-queries.cpp @@ -3808,15 +3808,23 @@ static bool resolveFnCallSpecial(Context* context, } else if (ci.numActuals() == 1 && ci.hasQuestionArg()) { // support type and param comparisons with '?' // TODO: will likely need adjustment once we are able to compare a + // partially-instantiated type's fields with '?' auto arg = ci.actual(0).type(); + bool result = false; + bool haveResult = true; if (arg.isType()) { - exprTypeOut = - QualifiedType(QualifiedType::PARAM, BoolType::get(context), - BoolParam::get(context, arg.type()->isAnyType())); + result = arg.type()->isAnyType(); } else if (arg.isParam()) { + result = arg.param() == nullptr; + } else { + haveResult = false; + } + result = ci.name() == USTR("==") ? result : !result; + if (haveResult) { exprTypeOut = QualifiedType(QualifiedType::PARAM, BoolType::get(context), - BoolParam::get(context, arg.param() == nullptr)); + BoolParam::get(context, result)); + return true; } } }