Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion codelab/solutions/exercise4.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ absl::StatusOr<std::unique_ptr<cel::Compiler>> MakeConfiguredCompiler() {
// Codelab part 1:
// Add a declaration for the map<string, V>.contains(string, V) function.
auto& checker_builder = builder->GetCheckerBuilder();
// Note: we use MakeMemberOverloadDecl instead of MakeOverloadDecl
// because the function is receiver style, meaning that it is called as
// e1.f(e2) instead of f(e1, e2).
CEL_ASSIGN_OR_RETURN(
cel::FunctionDecl decl,
cel::MakeFunctionDecl(
Expand All @@ -100,6 +103,8 @@ absl::StatusOr<std::unique_ptr<cel::Compiler>> MakeConfiguredCompiler() {
cel::MapType(checker_builder.arena(), cel::StringType(),
cel::TypeParamType("V")),
cel::StringType(), cel::TypeParamType("V"))));
// Note: we use MergeFunction instead of AddFunction because we are adding
// an overload to an already declared function with the same name.
CEL_RETURN_IF_ERROR(checker_builder.MergeFunction(decl));
return builder->Build();
}
Expand Down Expand Up @@ -135,7 +140,7 @@ class Evaluator {

if (bool value; result.GetValue(&value)) {
return value;
} else if (const CelError * value; result.GetValue(&value)) {
} else if (const CelError* value; result.GetValue(&value)) {
return *value;
} else {
return absl::InvalidArgumentError(
Expand Down