Skip to content

Commit

Permalink
[typer] recover Error in EThrow
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Mar 28, 2023
1 parent 129ce0d commit dc7f0c3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/typing/typer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1987,7 +1987,12 @@ and type_expr ?(mode=MGet) ctx (e,p) (with_type:WithType.t) =
| ETry (e1,catches) ->
type_try ctx e1 catches with_type p
| EThrow e ->
let e = type_expr ctx e WithType.value in
let e = try
type_expr ctx e WithType.value
with Error(e,p,_) ->
check_error ctx e p;
Texpr.Builder.make_null t_dynamic p
in
mk (TThrow e) (mono_or_dynamic ctx with_type p) p
| ENew (t,el) ->
type_new ctx t el with_type false p
Expand Down
7 changes: 7 additions & 0 deletions tests/misc/projects/Issue10170/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function f():Int {
throw invalid;
}

function main() {

}
3 changes: 3 additions & 0 deletions tests/misc/projects/Issue10170/compile-fail.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-cp src
-main Main
--interp
1 change: 1 addition & 0 deletions tests/misc/projects/Issue10170/compile-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Main.hx:2: characters 8-15 : Unknown identifier : invalid

0 comments on commit dc7f0c3

Please sign in to comment.