Skip to content

Commit

Permalink
Fix compiler warning and update Makefile (JuliaLang#26059)
Browse files Browse the repository at this point in the history
* Some accelerated `@generated` methods for converting `NamedTuple` to
   `Tuple` are excluded from compiler compilation.
 * The Makefile was quite stale in terms of tracking which files are used by
   the compiler compilation step. I added several and removed `hashing.jl`
   from the list.
  • Loading branch information
andyferris authored and JeffBezanson committed Feb 15, 2018
1 parent 38a2c9c commit 71d21ef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -177,24 +177,31 @@ CORE_SRCS := $(addprefix $(JULIAHOME)/, \
base/boot.jl \
base/docs/core.jl \
base/abstractarray.jl \
base/abstractdict.jl \
base/array.jl \
base/bitarray.jl \
base/bitset.jl \
base/bool.jl \
base/abstractdict.jl \
base/ctypes.jl \
base/error.jl \
base/essentials.jl \
base/generator.jl \
base/expr.jl \
base/generator.jl \
base/hashing.jl \
base/int.jl \
base/bitset.jl \
base/indices.jl \
base/iterators.jl \
base/namedtuple.jl \
base/number.jl \
base/operators.jl \
base/options.jl \
base/pair.jl \
base/pointer.jl \
base/promotion.jl \
base/range.jl \
base/reduce.jl \
base/reflection.jl \
base/traits.jl \
base/tuple.jl)
COMPILER_SRCS = $(sort $(shell find $(JULIAHOME)/base/compiler -name \*.jl))
BASE_SRCS := $(sort $(shell find $(JULIAHOME)/base -name \*.jl) $(shell find $(BUILDROOT)/base -name \*.jl))
Expand Down
14 changes: 8 additions & 6 deletions base/namedtuple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,16 @@ function convert(::Type{NamedTuple{names,T}}, nt::NamedTuple{names}) where {name
NamedTuple{names,T}(T(nt))
end

function Tuple(nt::NamedTuple{names}) where {names}
if @generated
return Expr(:tuple, Any[:(getfield(nt, $(QuoteNode(n)))) for n in names]...)
else
return tuple(nt...)
if nameof(@__MODULE__) === :Base
function Tuple(nt::NamedTuple{names}) where {names}
if @generated
return Expr(:tuple, Any[:(getfield(nt, $(QuoteNode(n)))) for n in names]...)
else
return tuple(nt...)
end
end
(::Type{T})(nt::NamedTuple) where {T <: Tuple} = convert(T, Tuple(nt))
end
(::Type{T})(nt::NamedTuple) where {T <: Tuple} = convert(T, Tuple(nt))

function show(io::IO, t::NamedTuple)
n = nfields(t)
Expand Down

0 comments on commit 71d21ef

Please sign in to comment.