Skip to content

Commit

Permalink
Handle undef refs in jl_copy_ast, fixes #9475
Browse files Browse the repository at this point in the history
[ci skip] checked on branch fix9475
passed osx
passed linux except for some network issue cloning package.
  • Loading branch information
ihnorton committed Dec 30, 2014
1 parent e6e4c0c commit cb1290e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,10 @@ static jl_value_t *copy_ast(jl_value_t *expr, jl_tuple_t *sp, int do_sp)

DLLEXPORT jl_value_t *jl_copy_ast(jl_value_t *expr)
{
if (jl_is_expr(expr)) {
if (expr == NULL) {
return NULL;
}
else if (jl_is_expr(expr)) {
jl_expr_t *e = (jl_expr_t*)expr;
size_t i, l = jl_array_len(e->args);
jl_expr_t *ne = NULL;
Expand Down
6 changes: 6 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1976,3 +1976,9 @@ function f9134()
end
end
@test_throws UndefVarError f9134()

# issue #9475
module I9475
arr = Array(Any, 1)
@eval @eval $arr[1] = 1
end

3 comments on commit cb1290e

@vtjnash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ihnorton
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timholy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for doing this, @ihnorton.

Please sign in to comment.