[ Feature Request ] Allow for a single throw statement as a body of an expression bodied lambda
- Dominant language
- C++
- Stars
- 18.7k
- Forks
- 3.1k
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 2
Description
### HHVM Version
4.27
### Operating System and Version
MacOS High Sierra
### Standalone code, or other way to reproduce the problem
```
<<__EntryPoint>>
function main(): void {
$_ = () ==> throw new \Exception();
}
```
### Actual result
```
$ hhvm test.hack
Fatal error: Uncaught Error: An expression is expected here. in /private/tmp/hhtest/test.hack:3
Stack trace:
#0 {main}
$ hh_client
Naming[2049] Unbound name: throw (a global constant)
--> test.hack
3 | $_ = () ==> throw new \Exception();
| ^^^^^
Typing[4106] Unbound global constant (Typing)
--> test.hack
3 | $_ = () ==> throw new \Exception();
| ^^^^^
Parsing[1002] An expression is expected here.
--> test.hack
3 | $_ = () ==> throw new \Exception();
|
3 errors found.
```
### Expected result
A lambda that throws when invoked.
Contributor guide
Research direction
Reproduce the issue from the standalone test.hack snippet, first running it through hhvm and hh_client to confirm the current parse and typing errors. Trace the handling of expression-bodied lambdas and throw syntax in the HHVM implementation. Done means the lambda is accepted and throws an exception when invoked, with hhvm and hh_client accepting the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, php
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100