Skip to content

Commit 70f9fda

Browse files
committed
Report unbound keywords more consistently with the rest of the language
1 parent bd998ea commit 70f9fda

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

core-misc.cc

+11-2
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,20 @@ namespace MNL_AUX_UUID { using namespace aux;
2828
// Translation Infrastructure //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2929
MNL_IF_WITH_MT(thread_local) decltype(symtab) pub::symtab;
3030

31+
namespace aux { namespace { struct stub {
32+
MNL_INLINE static val execute(bool) { MNL_UNREACHABLE(); }
33+
MNL_INLINE static void exec_in(val &&) { MNL_UNREACHABLE(); }
34+
MNL_INLINE static val exec_out() { MNL_UNREACHABLE(); }
35+
MNL_INLINE static bool is_rvalue() { return false; }
36+
MNL_INLINE static bool is_lvalue() { return false; }
37+
MNL_INLINE static code compile(code &&, const form &, const loc &_loc) { err_compile("invalid form", _loc); }
38+
}; }}
3139
code pub::compile(const form &form, const loc &_loc) { return // *** The Compiler Core Dispatcher! ***
3240
test<sym>(form) && symtab[cast<const sym &>(form)] ?
3341
symtab[cast<const sym &>(form)] :
34-
test<sym>(form) && ((const string &)cast<const sym &>(form))[0] >= 'a' && ((const string &)cast<const sym &>(form))[0] <= 'z' ?
35-
(err_compile("unbound keyword (nested in this context)", form._loc(_loc)), code{}) :
42+
test<sym>(form) && (((const string &)cast<const sym &>(form))[0] >= 'a' && ((const string &)cast<const sym &>(form))[0] <= 'z' ||
43+
((const string &)cast<const sym &>(form))[0] == '_' || ((const string &)cast<const sym &>(form))[0] == '`') ?
44+
MNL_AUX_INIT((code)stub{}) :
3645
test<long long>(form) || test<string>(form) || test<sym>(form) ?
3746
[&]()->code{ code make_lit(const val &); return make_lit(form); }() : // actually from MANOOL API
3847
form.is_list() && !form.empty() ?

lib-0.5-all.mnl

+5-5
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@
115115
else
116116
: if (Size[F] >= 8) & (F[2] == with') & (F[4] == do') & (F[6] == after') & F[1].IsSym[]
117117
then -- {on I with I do B after B; B; ...}
118-
{ var { U = {if Str[F[1]][0] <> "_"[0]$ then F[1]# else MakeSym[]} } in
118+
{ var { U = {if Str[F[1]][0] <> "_"[0]$ then F[1] else MakeSym[]}# } in
119119
: array of on# U with' F[3] do' F[5] after' {array of let# {array of: array of (=)' F[1] U} in'} + F[Range[7; Size[F]]]
120120
}
121121
else
122122
: if (Size[F] >= 6) & (F[2] == do') & (F[4] == after') & F[1].IsSym[]
123123
then -- {on I do B after B; B; ...}
124-
{ var { U = {if Str[F[1]][0] <> "_"[0]$ then F[1]# else MakeSym[]} } in
124+
{ var { U = {if Str[F[1]][0] <> "_"[0]$ then F[1] else MakeSym[]}# } in
125125
: array of on# U do' F[3] after' {array of let# {array of: array of (=)' F[1] U} in'} + F[Range[5; Size[F]]]
126126
}
127127
else -- fallback
@@ -137,7 +137,7 @@
137137
: proc { F } as
138138
: if (Size[F] == 4) & (F[2] == all')
139139
then -- {for {I = V; I = V; ...} all C}
140-
{ let { X = MakeSym[] } in
140+
{ let { X = MakeSym[]# } in
141141
: array of on# broad' X do' False# after'
142142
: array of do# True# after'
143143
: array of for# F[1] do'
@@ -147,7 +147,7 @@
147147
else
148148
: if (Size[F] == 4) & (F[2] == some')
149149
then -- {for {I = V; I = V; ...} some C}
150-
{ let { X = MakeSym[] } in
150+
{ let { X = MakeSym[]# } in
151151
: array of on# broad' X do' True# after'
152152
: array of do# False# after'
153153
: array of for# F[1] do'
@@ -282,7 +282,7 @@
282282
: proc { F } as
283283
: if (Size[F] >= 4) & (F[2] == in') & F[1].IsList[] & {for {E = F[1]} all E.IsSym[]}
284284
then -- {let {I; ...} in B; ...}
285-
{array of let# {array for {E = F[1]} of: array of (=)' E: if Str[E][0] <> "_"[0]$ then E# else MakeSym[]} in'} + F[Range[3; Size[F]]]
285+
{array of let# {array for {E = F[1]} of: array of (=)' E: if Str[E][0] <> "_"[0]$ then E# else MakeSym[]#} in'} + F[Range[3; Size[F]]]
286286
else -- fallback
287287
{array of let#} + F[Range[1; Size[F]]]
288288
}

0 commit comments

Comments
 (0)