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

Commit a5bcece

Browse files
lexidorfredemmott
authored andcommitted
Remove assert calls refine local instead of array index
1 parent 2ebe277 commit a5bcece

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/core/Node.hack

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ abstract xhp class node implements \XHPChild {
115115
$this->children[] = $new_child;
116116
}
117117
} else if ($child !== null) {
118-
assert($child is \XHPChild);
119-
$this->children[] = $child;
118+
$this->children[] = $child as \XHPChild;
120119
}
121120
return $this;
122121
}
@@ -733,17 +732,16 @@ abstract xhp class node implements \XHPChild {
733732
return tuple(false, $index);
734733

735734
case XHPChildrenConstraintType::CATEGORY:
736-
if (
737-
!C\contains_key($this->children, $index) ||
738-
!($this->children[$index] is node)
739-
) {
735+
if (!C\contains_key($this->children, $index)) {
736+
return tuple(false, $index);
737+
}
738+
$child = $this->children[$index];
739+
if (!$child is node) {
740740
return tuple(false, $index);
741741
}
742742
$category = $expr->getConstraintString()
743743
|> Str\replace($$, '__', ':')
744744
|> Str\replace($$, '_', '-');
745-
$child = $this->children[$index];
746-
assert($child is node);
747745
$categories = $child->__xhpCategoryDeclaration();
748746
if (($categories[$category] ?? 0) === 0) {
749747
return tuple(false, $index);

0 commit comments

Comments
 (0)