Skip to content

Commit 9fb8e10

Browse files
CEL Dev Teamcopybara-github
authored andcommitted
Return the first match from ResolveStatic()
PiperOrigin-RevId: 922297232
1 parent 2f0944e commit 9fb8e10

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

eval/eval/function_step.cc

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -286,20 +286,12 @@ absl::Status AbstractFunctionStep::Evaluate(ExecutionFrame* frame) const {
286286
absl::StatusOr<ResolveResult> ResolveStatic(
287287
absl::Span<const cel::Value> input_args,
288288
absl::Span<const cel::FunctionOverloadReference> overloads) {
289-
ResolveResult result = absl::nullopt;
290-
291289
for (const auto& overload : overloads) {
292290
if (ArgumentKindsMatch(overload.descriptor, input_args)) {
293-
// More than one overload matches our arguments.
294-
if (result.has_value()) {
295-
return absl::Status(absl::StatusCode::kInternal,
296-
"Cannot resolve overloads");
297-
}
298-
299-
result.emplace(overload);
291+
return overload;
300292
}
301293
}
302-
return result;
294+
return absl::nullopt;
303295
}
304296

305297
absl::StatusOr<ResolveResult> ResolveLazy(
@@ -315,7 +307,7 @@ absl::StatusOr<ResolveResult> ResolveLazy(
315307
input_args.begin(), input_args.end(), arg_types.begin(),
316308
[](const cel::Value& value) { return ValueKindToKind(value->kind()); });
317309

318-
cel::FunctionDescriptor matcher{name, receiver_style, arg_types};
310+
cel::FunctionDescriptor matcher{name, receiver_style, std::move(arg_types)};
319311

320312
const cel::ActivationInterface& activation = frame.activation();
321313
for (auto provider : providers) {

0 commit comments

Comments
 (0)