improve error message when an unbound id leads to a check for #%app or #%top (especially in the transformer environment)
svn: r12351
This commit is contained in:
parent
e10c33eccf
commit
8ec4e7f087
|
@ -5138,10 +5138,10 @@ scheme_compile_expand_expr(Scheme_Object *form, Scheme_Comp_Env *env,
|
||||||
Scheme_Compile_Expand_Info *rec, int drec,
|
Scheme_Compile_Expand_Info *rec, int drec,
|
||||||
int app_position)
|
int app_position)
|
||||||
{
|
{
|
||||||
Scheme_Object *name, *var, *stx, *normal, *can_recycle_stx = NULL;
|
Scheme_Object *name, *var, *stx, *normal, *can_recycle_stx = NULL, *orig_unbound_name = NULL;
|
||||||
Scheme_Env *menv = NULL;
|
Scheme_Env *menv = NULL;
|
||||||
GC_CAN_IGNORE char *not_allowed;
|
GC_CAN_IGNORE char *not_allowed;
|
||||||
int looking_for_top;
|
int looking_for_top, has_orig_unbound = 0;
|
||||||
|
|
||||||
top:
|
top:
|
||||||
|
|
||||||
|
@ -5256,8 +5256,12 @@ scheme_compile_expand_expr(Scheme_Object *form, Scheme_Comp_Env *env,
|
||||||
if (!var) {
|
if (!var) {
|
||||||
/* Top variable */
|
/* Top variable */
|
||||||
stx = top_symbol;
|
stx = top_symbol;
|
||||||
not_allowed = "reference to top-level identifier";
|
if (env->genv->module)
|
||||||
|
not_allowed = "reference to an unbound identifier";
|
||||||
|
else
|
||||||
|
not_allowed = "reference to a top-level identifier";
|
||||||
normal = top_expander;
|
normal = top_expander;
|
||||||
|
has_orig_unbound = 1;
|
||||||
form = find_name; /* in case it was re-mapped */
|
form = find_name; /* in case it was re-mapped */
|
||||||
looking_for_top = 1;
|
looking_for_top = 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -5353,6 +5357,8 @@ scheme_compile_expand_expr(Scheme_Object *form, Scheme_Comp_Env *env,
|
||||||
|
|
||||||
if (!var) {
|
if (!var) {
|
||||||
/* apply to global variable: compile it normally */
|
/* apply to global variable: compile it normally */
|
||||||
|
orig_unbound_name = find_name;
|
||||||
|
has_orig_unbound = 1;
|
||||||
} else if (SAME_TYPE(SCHEME_TYPE(var), scheme_local_type)
|
} else if (SAME_TYPE(SCHEME_TYPE(var), scheme_local_type)
|
||||||
|| SAME_TYPE(SCHEME_TYPE(var), scheme_local_unbox_type)) {
|
|| SAME_TYPE(SCHEME_TYPE(var), scheme_local_unbox_type)) {
|
||||||
/* apply to local variable: compile it normally */
|
/* apply to local variable: compile it normally */
|
||||||
|
@ -5499,11 +5505,30 @@ scheme_compile_expand_expr(Scheme_Object *form, Scheme_Comp_Env *env,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Not allowed this context! */
|
/* Not allowed this context! */
|
||||||
scheme_wrong_syntax(scheme_compile_stx_string, NULL, form,
|
char *phase, buf[30];
|
||||||
"bad syntax; %s is not allowed, "
|
if (env->genv->phase == 0)
|
||||||
"because no %S syntax transformer is bound",
|
phase = "";
|
||||||
not_allowed,
|
else if (env->genv->phase == 1)
|
||||||
SCHEME_STX_VAL(stx));
|
phase = " in the transformer environment";
|
||||||
|
else {
|
||||||
|
phase = buf;
|
||||||
|
sprintf(buf, " at phase %ld", env->genv->phase);
|
||||||
|
}
|
||||||
|
if (has_orig_unbound) {
|
||||||
|
scheme_wrong_syntax(scheme_compile_stx_string,
|
||||||
|
orig_unbound_name, form,
|
||||||
|
"unbound identifier%s "
|
||||||
|
"(and no %S syntax transformer is bound)",
|
||||||
|
phase,
|
||||||
|
SCHEME_STX_VAL(stx));
|
||||||
|
} else {
|
||||||
|
scheme_wrong_syntax(scheme_compile_stx_string, NULL, form,
|
||||||
|
"bad syntax; %s is not allowed, "
|
||||||
|
"because no %S syntax transformer is bound%s",
|
||||||
|
not_allowed,
|
||||||
|
SCHEME_STX_VAL(stx),
|
||||||
|
phase);
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user