diff --git a/src/macro/eval/evalStdLib.ml b/src/macro/eval/evalStdLib.ml index 70c56b5597a..1191c9976cd 100644 --- a/src/macro/eval/evalStdLib.ml +++ b/src/macro/eval/evalStdLib.ml @@ -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 diff --git a/tests/misc/projects/Issue11776/Main.hx b/tests/misc/projects/Issue11776/Main.hx new file mode 100644 index 00000000000..ce8957136a3 --- /dev/null +++ b/tests/misc/projects/Issue11776/Main.hx @@ -0,0 +1,10 @@ +class Main { + static function main() { + breakEverything(); + } + + static macro function breakEverything() { + eval.vm.Context.callMacroApi("oh no"); + return macro null; + } +} \ No newline at end of file diff --git a/tests/misc/projects/Issue11776/compile-fail.hxml b/tests/misc/projects/Issue11776/compile-fail.hxml new file mode 100644 index 00000000000..b30a755894b --- /dev/null +++ b/tests/misc/projects/Issue11776/compile-fail.hxml @@ -0,0 +1,2 @@ +--main Main +--interp \ No newline at end of file diff --git a/tests/misc/projects/Issue11776/compile-fail.hxml.stderr b/tests/misc/projects/Issue11776/compile-fail.hxml.stderr new file mode 100644 index 00000000000..c9d6764cd7c --- /dev/null +++ b/tests/misc/projects/Issue11776/compile-fail.hxml.stderr @@ -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 \ No newline at end of file