Skip to content

Commit

Permalink
fix #4919, macroexpander bug in "using" etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Nov 30, 2013
1 parent ed1a213 commit 534c8b3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -3007,6 +3007,7 @@ So far only the second case can actually occur.
(else
(case (car e)
((escape) (cadr e))
((using import importall export) (map unescape e))
((macrocall)
`(macrocall ,.(map (lambda (x)
(resolve-expansion-vars- x env m inarg))
Expand Down
1 change: 1 addition & 0 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ JL_CALLABLE(jl_f_new_module)

static jl_binding_t *new_binding(jl_sym_t *name)
{
assert(jl_is_symbol(name));
jl_binding_t *b = (jl_binding_t*)allocb(sizeof(jl_binding_t));
b->name = name;
b->value = NULL;
Expand Down
15 changes: 10 additions & 5 deletions src/toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ jl_value_t *jl_toplevel_eval_flex(jl_value_t *e, int fast)
jl_module_t *m = eval_import_path(ex->args);
if (m==NULL) return jl_nothing;
jl_sym_t *name = (jl_sym_t*)jl_cellref(ex->args, jl_array_len(ex->args)-1);
assert(jl_is_symbol(name));
if (!jl_is_symbol(name))
jl_error("syntax: malformed \"importall\" statement");
m = (jl_module_t*)jl_eval_global_var(m, name);
if (!jl_is_module(m))
jl_errorf("invalid %s statement: name exists but does not refer to a module", ex->head->name);
Expand All @@ -324,7 +325,8 @@ jl_value_t *jl_toplevel_eval_flex(jl_value_t *e, int fast)
jl_module_t *m = eval_import_path(ex->args);
if (m==NULL) return jl_nothing;
jl_sym_t *name = (jl_sym_t*)jl_cellref(ex->args, jl_array_len(ex->args)-1);
assert(jl_is_symbol(name));
if (!jl_is_symbol(name))
jl_error("syntax: malformed \"using\" statement");
jl_module_t *u = (jl_module_t*)jl_eval_global_var(m, name);
if (jl_is_module(u)) {
jl_module_using(jl_current_module, u);
Expand All @@ -339,15 +341,18 @@ jl_value_t *jl_toplevel_eval_flex(jl_value_t *e, int fast)
jl_module_t *m = eval_import_path(ex->args);
if (m==NULL) return jl_nothing;
jl_sym_t *name = (jl_sym_t*)jl_cellref(ex->args, jl_array_len(ex->args)-1);
assert(jl_is_symbol(name));
if (!jl_is_symbol(name))
jl_error("syntax: malformed \"import\" statement");
jl_module_import(jl_current_module, m, name);
return jl_nothing;
}

if (ex->head == export_sym) {
for(size_t i=0; i < jl_array_len(ex->args); i++) {
jl_module_export(jl_current_module,
(jl_sym_t*)jl_cellref(ex->args, i));
jl_sym_t *name = (jl_sym_t*)jl_cellref(ex->args, i);
if (!jl_is_symbol(name))
jl_error("syntax: malformed \"export\" statement");
jl_module_export(jl_current_module, name);
}
return jl_nothing;
}
Expand Down

0 comments on commit 534c8b3

Please sign in to comment.