Skip to content

Commit

Permalink
Fix mistakes in handling of == ?
Browse files Browse the repository at this point in the history
- Return true from resolveFnCallSpecial if handled
- Invert result for !=

Signed-off-by: Anna Rift <[email protected]>
  • Loading branch information
riftEmber committed Nov 22, 2024
1 parent 0d61e74 commit 262abef
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions frontend/lib/resolution/resolution-queries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down

0 comments on commit 262abef

Please sign in to comment.