Skip to content

Commit

Permalink
fix #12003
Browse files Browse the repository at this point in the history
julia_const_to_llvm sometimes returned a GlobalVariable instead of the expected
Constant. should only return a GlobalVariable at the outermost level.
  • Loading branch information
JeffBezanson committed Jul 3, 2015
1 parent 2ea17a0 commit ba064ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static Value *uint_cnvt(Type *to, Value *x)
}

#define LLVM_FP(a,b) APFloat(a,b)
static Constant *julia_const_to_llvm(jl_value_t *e)
static Constant *julia_const_to_llvm(jl_value_t *e, bool nested=false)
{
jl_value_t *jt = jl_typeof(e);
jl_datatype_t *bt = (jl_datatype_t*)jt;
Expand Down Expand Up @@ -212,7 +212,7 @@ static Constant *julia_const_to_llvm(jl_value_t *e)
else if (f == jl_false)
val = ConstantInt::get(T_int8,0);
else
val = julia_const_to_llvm(f);
val = julia_const_to_llvm(f, true);
if (val == NULL) {
JL_GC_POP();
return NULL;
Expand All @@ -238,7 +238,10 @@ static Constant *julia_const_to_llvm(jl_value_t *e)
assert(at);
init = ConstantArray::get(at, ArrayRef<Constant*>(fields,llvm_nf));
}
return new GlobalVariable(*jl_Module, t, true, GlobalVariable::ExternalLinkage, init);
if (nested)
return init;
else
return new GlobalVariable(*jl_Module, t, true, GlobalVariable::ExternalLinkage, init);
}
return NULL;
}
Expand Down
5 changes: 5 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3101,3 +3101,8 @@ function find_tvar10930(arg)
return 1
end
@test find_tvar10930(Vararg{Int}) === 1

# issue #12003
const DATE12003 = DateTime(1917,1,1)
failure12003(dt=DATE12003) = Dates.year(dt)
@test isa(failure12003(), Integer)

0 comments on commit ba064ad

Please sign in to comment.