From fd0075c68ea14ffc2a8e49fe0c24f12680d1d54e Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Fri, 19 Sep 2014 10:30:01 -0400 Subject: [PATCH] move `reinterpret` error check inside `box`. fixes #8088 --- base/number.jl | 7 +------ src/intrinsics.cpp | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/base/number.jl b/base/number.jl index a0b641346e040..68d5f0628e53d 100644 --- a/base/number.jl +++ b/base/number.jl @@ -39,12 +39,7 @@ done(x::Number, state) = state isempty(x::Number) = false in(x::Number, y::Number) = x == y -function reinterpret{T}(::Type{T}, x) - if !isbits(T) - error("cannot reinterpret to type ", T) - end - box(T,x) -end +reinterpret{T,S}(::Type{T}, x::S) = box(T,unbox(S,x)) map(f::Callable, x::Number) = f(x) diff --git a/src/intrinsics.cpp b/src/intrinsics.cpp index 1a6a4518adf01..0a6db36988a7c 100644 --- a/src/intrinsics.cpp +++ b/src/intrinsics.cpp @@ -393,7 +393,8 @@ static Value *generic_box(jl_value_t *targ, jl_value_t *x, jl_codectx_t *ctx) if (bt == NULL) { } else if (!jl_is_bitstype(bt)) { - jl_error("box: expected bits type as first argument"); + emit_error("reinterpret: expected bits type as first argument", ctx); + return UndefValue::get(jl_pvalue_llvmt); } else { llvmt = julia_type_to_llvm(bt); @@ -409,7 +410,6 @@ static Value *generic_box(jl_value_t *targ, jl_value_t *x, jl_codectx_t *ctx) if (nb == -1) { emit_error("box: could not determine argument size", ctx); return UndefValue::get(jl_pvalue_llvmt); - //jl_error("box: could not determine argument size"); } if (llvmt == NULL)