Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
Remove assert calls refine local instead of array index
Browse files Browse the repository at this point in the history
  • Loading branch information
lexidor authored and fredemmott committed Dec 18, 2020
1 parent 2ebe277 commit a5bcece
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/core/Node.hack
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ abstract xhp class node implements \XHPChild {
$this->children[] = $new_child;
}
} else if ($child !== null) {
assert($child is \XHPChild);
$this->children[] = $child;
$this->children[] = $child as \XHPChild;
}
return $this;
}
Expand Down Expand Up @@ -733,17 +732,16 @@ abstract xhp class node implements \XHPChild {
return tuple(false, $index);

case XHPChildrenConstraintType::CATEGORY:
if (
!C\contains_key($this->children, $index) ||
!($this->children[$index] is node)
) {
if (!C\contains_key($this->children, $index)) {
return tuple(false, $index);
}
$child = $this->children[$index];
if (!$child is node) {
return tuple(false, $index);
}
$category = $expr->getConstraintString()
|> Str\replace($$, '__', ':')
|> Str\replace($$, '_', '-');
$child = $this->children[$index];
assert($child is node);
$categories = $child->__xhpCategoryDeclaration();
if (($categories[$category] ?? 0) === 0) {
return tuple(false, $index);
Expand Down

0 comments on commit a5bcece

Please sign in to comment.