Skip to content

Commit

Permalink
prevent merging of type error code from different locations. fixes Ju…
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jul 27, 2014
1 parent da84e7e commit 9a16d18
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ void jl_type_error_rt(const char *fname, const char *context,
jl_throw(ex);
}

void jl_type_error_rt_line(const char *fname, const char *context,
jl_value_t *ty, jl_value_t *got, int line)
{
jl_type_error_rt(fname, context, ty, got);
}

void jl_type_error(const char *fname, jl_value_t *expected, jl_value_t *got)
{
jl_type_error_rt(fname, "", expected, got);
Expand Down
5 changes: 3 additions & 2 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,9 +770,10 @@ static void emit_type_error(Value *x, jl_value_t *type, const std::string &msg,
ArrayRef<Value*>(zeros));
Value *msg_val = builder.CreateGEP(stringConst(msg),
ArrayRef<Value*>(zeros));
builder.CreateCall4(prepare_call(jltypeerror_func),
builder.CreateCall5(prepare_call(jltypeerror_func),
fname_val, msg_val,
literal_pointer_val(type), boxed(x,ctx));
literal_pointer_val(type), boxed(x,ctx),
ConstantInt::get(T_int32, ctx->lineno));
}

static void emit_typecheck(Value *x, jl_value_t *type, const std::string &msg,
Expand Down
6 changes: 3 additions & 3 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4116,13 +4116,13 @@ static void init_julia_llvm_env(Module *m)
te_args.push_back(T_pint8);
te_args.push_back(jl_pvalue_llvmt);
te_args.push_back(jl_pvalue_llvmt);
te_args.push_back(T_int32);
jltypeerror_func =
Function::Create(FunctionType::get(T_void, te_args, false),
Function::ExternalLinkage,
"jl_type_error_rt", m);
"jl_type_error_rt_line", m);
jltypeerror_func->setDoesNotReturn();
add_named_global(jltypeerror_func,
(void*)&jl_type_error_rt);
add_named_global(jltypeerror_func, (void*)&jl_type_error_rt_line);

std::vector<Type *> args_2ptrs(0);
args_2ptrs.push_back(jl_pvalue_llvmt);
Expand Down
2 changes: 2 additions & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,8 @@ DLLEXPORT void jl_too_many_args(const char *fname, int max);
DLLEXPORT void jl_type_error(const char *fname, jl_value_t *expected, jl_value_t *got);
DLLEXPORT void jl_type_error_rt(const char *fname, const char *context,
jl_value_t *ty, jl_value_t *got);
DLLEXPORT void jl_type_error_rt_line(const char *fname, const char *context,
jl_value_t *ty, jl_value_t *got, int line);
jl_value_t *jl_no_method_error(jl_function_t *f, jl_value_t **args, size_t na);
DLLEXPORT void jl_undefined_var_error(jl_sym_t *var);
void jl_check_type_tuple(jl_tuple_t *t, jl_sym_t *name, const char *ctx);
Expand Down

0 comments on commit 9a16d18

Please sign in to comment.