Skip to content

Commit

Permalink
Avoid spurious list computation
Browse files Browse the repository at this point in the history
  • Loading branch information
ajreynol committed Apr 3, 2024
1 parent 66e6445 commit bc7facb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/kind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,5 +224,20 @@ bool isLiteralOp(Kind k)
}
return false;
}
bool isListLiteralOp(Kind k)
{
switch (k)
{
case Kind::EVAL_NIL:
case Kind::EVAL_CONS:
case Kind::EVAL_CONCAT:
case Kind::EVAL_EXTRACT:
case Kind::EVAL_FIND:
return true;
default:
break;
}
return false;
}

} // namespace alfc
2 changes: 2 additions & 0 deletions src/kind.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ bool isSymbol(Kind k);
bool isLiteral(Kind k);
/** */
bool isLiteralOp(Kind k);
/** Is k a list literal operator? */
bool isListLiteralOp(Kind k);

} // namespace alfc

Expand Down
5 changes: 5 additions & 0 deletions src/type_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,10 @@ Expr TypeChecker::evaluateLiteralOpInternal(
Trace("type_checker") << "...value-evaluates to " << lit << std::endl;
return lit;
}
if (!isListLiteralOp(k))
{
return d_null;
}
// otherwise, maybe a list operation
ExprValue* op = args[0];
// strip off parameterized to look up AppInfo
Expand Down Expand Up @@ -1398,6 +1402,7 @@ bool TypeChecker::computedParameterizedInternal(AppInfo* ai,
{
// if not in an application, we fail
Warning() << "Failed to determine parameters for " << hd << std::endl;
AlwaysAssert(false);
return false;
}
else
Expand Down

0 comments on commit bc7facb

Please sign in to comment.