1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-21 02:37:49 +00:00

Support looking up missing symbols during compilation

This commit is contained in:
Michael Camilleri
2022-01-21 13:07:11 +09:00
parent 2f3b4c8bfb
commit 1eb34989d4
3 changed files with 23 additions and 2 deletions

View File

@@ -26,5 +26,18 @@
(assert (< 11899423.08 (math/gamma 11.5) 11899423.085) "math/gamma")
(assert (< 2605.1158 (math/log-gamma 500) 2605.1159) "math/log-gamma")
# missing symbols
(def replacement 10)
(defn lookup-symbol [sym env] (dyn 'replacement))
(setdyn :missing-symbol lookup-symbol)
(assert (= (eval-string "(+ a 5)") 15) "lookup missing symbol")
(setdyn :missing-symbol nil)
(assert-error "compile error" (eval-string "(+ a 5)"))
(end-suite)