mirror of
https://github.com/janet-lang/janet
synced 2024-12-25 07:50:27 +00:00
Merge pull request #1185 from chris-chambers/macro-lints-fix
Fix order in which *macro-lints* is set during expansion
This commit is contained in:
commit
e2459cfb47
@ -746,12 +746,14 @@ static int macroexpand1(
|
|||||||
int lock = janet_gclock();
|
int lock = janet_gclock();
|
||||||
Janet mf_kw = janet_ckeywordv("macro-form");
|
Janet mf_kw = janet_ckeywordv("macro-form");
|
||||||
janet_table_put(c->env, mf_kw, x);
|
janet_table_put(c->env, mf_kw, x);
|
||||||
|
Janet ml_kw = janet_ckeywordv("macro-lints");
|
||||||
|
if (c->lints) {
|
||||||
|
janet_table_put(c->env, ml_kw, janet_wrap_array(c->lints));
|
||||||
|
}
|
||||||
Janet tempOut;
|
Janet tempOut;
|
||||||
JanetSignal status = janet_continue(fiberp, janet_wrap_nil(), &tempOut);
|
JanetSignal status = janet_continue(fiberp, janet_wrap_nil(), &tempOut);
|
||||||
janet_table_put(c->env, mf_kw, janet_wrap_nil());
|
janet_table_put(c->env, mf_kw, janet_wrap_nil());
|
||||||
if (c->lints) {
|
janet_table_put(c->env, ml_kw, janet_wrap_nil());
|
||||||
janet_table_put(c->env, janet_ckeywordv("macro-lints"), janet_wrap_array(c->lints));
|
|
||||||
}
|
|
||||||
janet_gcunlock(lock);
|
janet_gcunlock(lock);
|
||||||
if (status != JANET_SIGNAL_OK) {
|
if (status != JANET_SIGNAL_OK) {
|
||||||
const uint8_t *es = janet_formatc("(macro) %V", tempOut);
|
const uint8_t *es = janet_formatc("(macro) %V", tempOut);
|
||||||
|
@ -886,5 +886,22 @@
|
|||||||
(assert (= (thunk) 1) "delay 3")
|
(assert (= (thunk) 1) "delay 3")
|
||||||
(assert (= counter 1) "delay 4")
|
(assert (= counter 1) "delay 4")
|
||||||
|
|
||||||
(end-suite)
|
# maclintf
|
||||||
|
(def env (table/clone (curenv)))
|
||||||
|
((compile '(defmacro foo [] (maclintf :strict "oops")) env :anonymous))
|
||||||
|
(def lints @[])
|
||||||
|
(compile (tuple/setmap '(foo) 1 2) env :anonymous lints)
|
||||||
|
(assert (deep= lints @[[:strict 1 2 "oops"]]) "maclintf 1")
|
||||||
|
|
||||||
|
(def env (table/clone (curenv)))
|
||||||
|
((compile '(defmacro foo [& body] (maclintf :strict "foo-oops") ~(do ,;body)) env :anonymous))
|
||||||
|
((compile '(defmacro bar [] (maclintf :strict "bar-oops")) env :anonymous))
|
||||||
|
(def lints @[])
|
||||||
|
# Compile (foo (bar)), but with explicit source map values
|
||||||
|
(def bar-invoke (tuple/setmap '(bar) 3 4))
|
||||||
|
(compile (tuple/setmap ~(foo ,bar-invoke) 1 2) env :anonymous lints)
|
||||||
|
(assert (deep= lints @[[:strict 1 2 "foo-oops"]
|
||||||
|
[:strict 3 4 "bar-oops"]])
|
||||||
|
"maclintf 2")
|
||||||
|
|
||||||
|
(end-suite)
|
||||||
|
Loading…
Reference in New Issue
Block a user