Skip to content

Commit 5296045

Browse files
committedMay 29, 2014
fix bug in map: my technique only works with typejoin, not promote_type
this gives us a useful type bound for every computed element. using promote_type, the computed elements can be almost anything, and need to be converted using a dynamic dispatch to convert().
1 parent 26ad28d commit 5296045

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎base/abstractarray.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ function map_to!{T}(f::Callable, offs, dest::AbstractArray{T}, A::AbstractArray)
12581258
el = f(A[i])
12591259
S = typeof(el)
12601260
if (S !== T) && !(S <: T)
1261-
R = promote_type(T, S)
1261+
R = typejoin(T, S)
12621262
new = similar(dest, R)
12631263
copy!(new,1, dest,1, i-1)
12641264
new[i] = el
@@ -1283,7 +1283,7 @@ function map_to!{T}(f::Callable, offs, dest::AbstractArray{T}, A::AbstractArray,
12831283
el = f(A[i], B[i])
12841284
S = typeof(el)
12851285
if (S !== T) && !(S <: T)
1286-
R = promote_type(T, S)
1286+
R = typejoin(T, S)
12871287
new = similar(dest, R)
12881288
copy!(new,1, dest,1, i-1)
12891289
new[i] = el
@@ -1313,7 +1313,7 @@ function map_to!{T}(f::Callable, offs, dest::AbstractArray{T}, As::AbstractArray
13131313
el = f(map(ith, As)...)
13141314
S = typeof(el)
13151315
if (S !== T) && !(S <: T)
1316-
R = promote_type(T, S)
1316+
R = typejoin(T, S)
13171317
new = similar(dest, R)
13181318
copy!(new,1, dest,1, i-1)
13191319
new[i] = el

0 commit comments

Comments
 (0)
Please sign in to comment.