Skip to content

Commit

Permalink
fail nicer if we can't find a macro function
Browse files Browse the repository at this point in the history
see #11776
  • Loading branch information
Simn committed Oct 15, 2024
1 parent 39aceb1 commit 9aa9911
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/macro/eval/evalStdLib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,12 @@ module StdContext = struct
else raise (EvalDebugMisc.BreakHere)
)

let callMacroApi = vfun1 (fun f ->
let callMacroApi = vfun1 (fun f ->
let f = decode_string f in
Hashtbl.find GlobalState.macro_lib f
try
Hashtbl.find GlobalState.macro_lib f
with Not_found ->
exc_string ("Could not find macro function \"" ^ f ^ "\"")
)

let plugins = ref PMap.empty
Expand Down
10 changes: 10 additions & 0 deletions tests/misc/projects/Issue11776/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Main {
static function main() {
breakEverything();
}

static macro function breakEverything() {
eval.vm.Context.callMacroApi("oh no");
return macro null;
}
}
2 changes: 2 additions & 0 deletions tests/misc/projects/Issue11776/compile-fail.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--main Main
--interp
3 changes: 3 additions & 0 deletions tests/misc/projects/Issue11776/compile-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Main.hx:3: characters 3-20 : Uncaught exception Could not find macro function "oh no"
Main.hx:7: characters 3-40 : Called from here
Main.hx:3: characters 3-20 : Called from here

0 comments on commit 9aa9911

Please sign in to comment.