Skip to content

Commit

Permalink
fix #11675, problem accessing fields of type Union()
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jun 12, 2015
1 parent 84f14d1 commit 190afa6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,10 @@ static Value *emit_getfield_knownidx(Value *strct, unsigned idx, jl_datatype_t *
jl_value_t *jfty = jl_field_type(jt,idx);
Type *elty = julia_type_to_llvm(jfty);
assert(elty != NULL);
if (jfty == jl_bottom_type) {
raise_exception_unless(ConstantInt::get(T_int1,0), prepare_global(jlundeferr_var), ctx);
return UndefValue::get(jl_pvalue_llvmt);
}
if (elty == T_void)
return ghostValue(jfty);
Value *fldv = NULL;
Expand Down
8 changes: 1 addition & 7 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2142,13 +2142,7 @@ static Value *emit_known_call(jl_value_t *ff, jl_value_t **args, size_t nargs,
else if (f->fptr == &jl_f_throw && nargs==1) {
Value *arg1 = boxed(emit_expr(args[1], ctx), ctx);
JL_GC_POP();
#ifdef LLVM37
builder.CreateCall(prepare_call(jlthrow_line_func), {arg1,
ConstantInt::get(T_int32, ctx->lineno)});
#else
builder.CreateCall2(prepare_call(jlthrow_line_func), arg1,
ConstantInt::get(T_int32, ctx->lineno));
#endif
raise_exception_unless(ConstantInt::get(T_int1,0), arg1, ctx);
return V_null;
}
else if (f->fptr == &jl_f_arraylen && nargs==1) {
Expand Down
12 changes: 12 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2939,3 +2939,15 @@ function f11295(x...)
call = Expr(x...)
end
@test isa(f11295(:a,:b), Expr)

# issue #11675
immutable T11675{T}
x::T
T11675() = new()
end
let x = T11675{Union()}()
function f(x)
x.x + 1
end
@test_throws UndefRefError f(x)
end
3 changes: 3 additions & 0 deletions test/nullable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -272,3 +272,6 @@ end
@test isnull(convert(Nullable, nothing))
@test isnull(convert(Nullable{Int}, nothing))
@test isa(convert(Nullable{Int}, nothing), Nullable{Int})

# issue #11675
@test repr(Nullable()) == "Nullable{Union()}()"

2 comments on commit 190afa6

@tkelman
Copy link
Contributor

Choose a reason for hiding this comment

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

careful with single-letter variable names in the tests... #11677

(or is that a separate bug with let not doing what it's supposed to?)

@yuyichao
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that this is causing SegFault in codegen on 32-bit linux.

https://travis-ci.org/JuliaLang/julia/builds/66554916

Please sign in to comment.