-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix expression tree nesting with await bug
Summary: The lowerer introduces lambdas to allow lists of statements in expression trees, e.g. ``ExampleDsl`{$x = 1; $y = 2;}` `` lowers to ``ExampleDsl`(() ==> {$x = 1; $y = 2;})()` `` before desugaring. This is an expression tree lambda, not a Hack lambda, and thus processing it shouldn't interfere with the code looking for awaits and yields should they appear in splices, nor should we forget if we are in an enclosing async Hack function. However, the call to `reset_for_function_body` was doing exactly that. Improve error message if a yield appears in an expression tree Reviewed By: andrewjkennedy Differential Revision: D66822415 fbshipit-source-id: 1b89af3ab838473c51d641331fdce73bdab010a4
- Loading branch information
1 parent
54551f8
commit fa0ef51
Showing
7 changed files
with
45 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
hphp/hack/test/typecheck/expression_trees/nesting/await.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?hh | ||
<<file: __EnableUnstableFeatures('expression_trees')>> | ||
|
||
async function g(): Awaitable<ExampleDslExpression<ExampleInt>> { | ||
return ExampleDsl`1`; | ||
} | ||
|
||
async function f(): Awaitable<void> { | ||
ExampleDsl`${ExampleDsl`${await g()}`}`; | ||
ExampleDsl`{ | ||
${await g()}; | ||
}`; | ||
ExampleDsl`${ | ||
ExampleDsl`{ | ||
1; | ||
${await g()}; | ||
}` | ||
}`; | ||
ExampleDsl`{ | ||
${ExampleDsl`${await g()}`}; | ||
}`; | ||
ExampleDsl`{ | ||
${await g()}; | ||
${ExampleDsl`${await g()}`}; | ||
}`; | ||
ExampleDsl`{ | ||
${ | ||
ExampleDsl`{ | ||
${await g()}; | ||
}` | ||
}; | ||
}`; | ||
} |
1 change: 1 addition & 0 deletions
1
hphp/hack/test/typecheck/expression_trees/nesting/await.php.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
No errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Fatal error: Expression trees only support simple lambdas, without features like `async`, generators or capabilities. in %s/blocks_yield.php on line 14 | ||
Fatal error: `yield` is not supported in expression trees. in %s/blocks_yield.php on line 12 |