From 74a5dd56618f70cbd53755339a95d7d5d8a65c23 Mon Sep 17 00:00:00 2001 From: Stiopa Koltsov Date: Wed, 2 Oct 2024 10:56:07 -0700 Subject: [PATCH] set & should fail if RHS is not set Reviewed By: perehonchuk Differential Revision: D63740714 fbshipit-source-id: 925d99bd96ba5f69fad161720adca071cd152e4c --- starlark/src/values/types/set/value.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/starlark/src/values/types/set/value.rs b/starlark/src/values/types/set/value.rs index 98fb0ee59..474fa02bf 100644 --- a/starlark/src/values/types/set/value.rs +++ b/starlark/src/values/types/set/value.rs @@ -276,12 +276,13 @@ where // Set intersection fn bit_and(&self, rhs: Value<'v>, heap: &'v Heap) -> crate::Result> { + let rhs = SetRef::unpack_value_opt(rhs) + .map_or_else(|| ValueError::unsupported_with(self, "&", rhs), Ok)?; + let mut items = SmallSet::new(); if self.0.content().is_empty() { return Ok(heap.alloc(SetData { content: items })); } - let rhs = SetRef::unpack_value_opt(rhs) - .map_or_else(|| ValueError::unsupported_with(self, "&", rhs), Ok)?; for h in rhs.aref.iter_hashed() { if self.0.content().contains_hashed(h.as_ref()) {