HaxeFoundation / HaxeFoundation/haxe
break outside loop causes compiler assertion
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
```haxe
function main() {
@:coroutine function f() {
break;
}
}
```
```
Fatal error: exception Failure("hd")
Raised at Stdlib.failwith in file "stdlib.ml", line 29, characters 17-33
Called from Stdlib__List.hd in file "list.ml" (inlined), line 30, characters 10-23
Called from CoroFromTexpr.expr_to_coro.loop in file "src/coro/coroFromTexpr.ml", line 217, characters 44-65
Called from CoroFromTexpr.expr_to_coro.loop_assign in file "src/coro/coroFromTexpr.ml", line 380, characters 11-24
```
The typer doesn't error hard enough for the coro transformer to not run, and it then gets confused.
Contributor guide
Research direction
Reproduce the Haxe snippet and inspect src/coro/coroFromTexpr.ml around lines 217 and 380, where the assertion is reported. Check how the typer handles break outside a loop before the coroutine transformer runs. Done means the invalid program produces a compiler error instead of the coroutine assertion.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100