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

Commit 7d2d31e

Browse files
committed
Fix Node::__construct $children type
Hack now typechecks XHP constructors (facebook/hhvm@af6f350) which revealed this error.
1 parent 074b88b commit 7d2d31e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/core/Node.hack

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ abstract xhp class node implements \XHPChild {
4949
*/
5050
final public function __construct(
5151
KeyedTraversable<string, mixed> $attributes,
52-
Traversable<\XHPChild> $children,
52+
Traversable<?\XHPChild> $children,
5353
dynamic ...$debug_info
5454
) {
5555
invariant(

tests/BasicsTest.hack

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ class BasicsTest extends Facebook\HackTest\HackTest {
246246
expect(await $xhp->toStringAsync())->toEqual('<div>herpderp</div>');
247247
}
248248

249+
public async function testScalarChildren(): Awaitable<void> {
250+
$xhp = <div>{42}{' str '}{3.14}{null}</div>;
251+
expect(await $xhp->toStringAsync())->toEqual('<div>42 str 3.14</div>');
252+
}
253+
249254
public async function testEscaping(): Awaitable<void> {
250255
$xhp = <div>{'foo<SCRIPT>bar'}</div>;
251256
expect(await $xhp->toStringAsync())->toEqual(

0 commit comments

Comments
 (0)