Skip to content

Commit

Permalink
BUGFIX - pop errors in validate_selection_conflict
Browse files Browse the repository at this point in the history
Reviewed By: tyao1

Differential Revision: D39521363

fbshipit-source-id: d2fa981569d71e194cec64dd215b9087c99a73f8
  • Loading branch information
Jianfeng Chen authored and facebook-github-bot committed Sep 14, 2022
1 parent 80db951 commit 9790484
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<'s, B: LocationAgnosticBehavior + Sync> ValidateSelectionConflict<'s, B> {

fn validate_program(&self, program: &'s Program) -> DiagnosticsResult<()> {
if self.further_optimization {
self.prewarm_fragments(program);
self.prewarm_fragments(program)?;
}

par_try_map(&program.operations, |operation| {
Expand All @@ -86,7 +86,7 @@ impl<'s, B: LocationAgnosticBehavior + Sync> ValidateSelectionConflict<'s, B> {
Ok(())
}

fn prewarm_fragments(&self, program: &'s Program) {
fn prewarm_fragments(&self, program: &'s Program) -> DiagnosticsResult<()> {
// Validate the fragments in topology order.
let mut unclaimed_fragment_queue: VecDeque<FragmentDefinitionName> = VecDeque::new();

Expand Down Expand Up @@ -118,11 +118,13 @@ impl<'s, B: LocationAgnosticBehavior + Sync> ValidateSelectionConflict<'s, B> {

let dummy_hashset = HashSet::new();
while let Some(visiting) = unclaimed_fragment_queue.pop_front() {
let _ = self.validate_and_collect_fragment(
if let Err(e) = self.validate_and_collect_fragment(
program
.fragment(visiting)
.expect("fragment must have been registered"),
);
) {
return Err(e);
}

for used_by in dag_used_by.get(&visiting).unwrap_or(&dummy_hashset) {
// fragment "used_by" now can assume "...now" cached.
Expand All @@ -133,6 +135,7 @@ impl<'s, B: LocationAgnosticBehavior + Sync> ValidateSelectionConflict<'s, B> {
}
}
}
Ok(())
}

fn validate_operation(&self, operation: &'s OperationDefinition) -> DiagnosticsResult<()> {
Expand Down Expand Up @@ -268,7 +271,7 @@ impl<'s, B: LocationAgnosticBehavior + Sync> ValidateSelectionConflict<'s, B> {
*l,
*r,
) {
errors.push(err)
errors.push(err);
};
}
if has_same_type_reference_wrapping(&l_definition.type_, &r_definition.type_) {
Expand Down Expand Up @@ -313,7 +316,7 @@ impl<'s, B: LocationAgnosticBehavior + Sync> ValidateSelectionConflict<'s, B> {
*l,
*r,
) {
errors.push(err)
errors.push(err);
};
} else if l_definition.type_ != r_definition.type_ {
errors.push(
Expand Down Expand Up @@ -361,7 +364,7 @@ impl<'s, B: LocationAgnosticBehavior + Sync> ValidateSelectionConflict<'s, B> {
}

// save the verified pair into cache
if self.further_optimization && errors.is_empty() {
if self.further_optimization {
self.verified_fields_pair.insert((addr1, addr2));
}
}
Expand Down

0 comments on commit 9790484

Please sign in to comment.