Skip to content

Commit

Permalink
set & should fail if RHS is not set
Browse files Browse the repository at this point in the history
Reviewed By: perehonchuk

Differential Revision: D63740714

fbshipit-source-id: 925d99bd96ba5f69fad161720adca071cd152e4c
  • Loading branch information
stepancheg authored and facebook-github-bot committed Oct 2, 2024
1 parent f10ef49 commit 74a5dd5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions starlark/src/values/types/set/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,13 @@ where

// Set intersection
fn bit_and(&self, rhs: Value<'v>, heap: &'v Heap) -> crate::Result<Value<'v>> {
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()) {
Expand Down

0 comments on commit 74a5dd5

Please sign in to comment.