Skip to content

Commit

Permalink
Fix Symbol redefinition warnings (#16173)
Browse files Browse the repository at this point in the history
* Fix indent in test/core.jl

* Revert the 2:end change from a9df7e9

there are dot operators that are more than 2 characters long that these
loops may want to extend to in the future, leaving the 2:end the way it
was will be less error prone

* Split Symbol constructors from expr.jl to avoid redefinition warning

expr.jl is included in both Inference and Base, so split these methods
into coreimg.jl and sysimg.jl

* Clean up straggler mentions of symbol

and an unnecessary identity method
  • Loading branch information
tkelman committed May 4, 2016
1 parent e659330 commit 81bc6e7
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
6 changes: 6 additions & 0 deletions base/coreimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ if !isdefined(Main, :Base)
(::Type{T}){T}(arg) = convert(T, arg)::T
end

# Symbol constructors
Symbol(s::ASCIIString) = Symbol(s.data)
Symbol(s::UTF8String) = Symbol(s.data)
Symbol(a::Array{UInt8,1}) =
ccall(:jl_symbol_n, Ref{Symbol}, (Ptr{UInt8}, Int32), a, length(a))

# core array operations
include("abstractarray.jl")
include("array.jl")
Expand Down
2 changes: 1 addition & 1 deletion base/dates/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ end
(-)(y::Period,x::TimeType) = x - y

for op in (:.+, :.-)
op_ = Symbol(string(op)[2])
op_ = Symbol(string(op)[2:end])
@eval begin
# GeneralPeriod, AbstractArray{TimeType}
($op){T<:TimeType}(x::AbstractArray{T}, y::GeneralPeriod) =
Expand Down
4 changes: 2 additions & 2 deletions base/dates/periods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ for (op,Ty,Tz) in ((:.*,Real,:P),
(:.%,:P,:P),
(:mod,:P,:P))
sop = string(op)
op_ = sop[1] == '.' ? Symbol(sop[2]) : op
op_ = sop[1] == '.' ? Symbol(sop[2:end]) : op
@eval begin
function ($op){P<:Period}(X::StridedArray{P},y::$Ty)
Z = similar(X, $Tz)
Expand Down Expand Up @@ -234,7 +234,7 @@ GeneralPeriod = Union{Period,CompoundPeriod}
(+){P<:GeneralPeriod}(x::StridedArray{P}) = x

for op in (:.+, :.-)
op_ = Symbol(string(op)[2])
op_ = Symbol(string(op)[2:end])
@eval begin
function ($op){P<:GeneralPeriod}(X::StridedArray{P},y::GeneralPeriod)
Z = similar(X, CompoundPeriod)
Expand Down
1 change: 0 additions & 1 deletion base/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,6 @@ export
gensym,
macroexpand,
parse,
symbol,

# help and reflection
apropos,
Expand Down
7 changes: 0 additions & 7 deletions base/expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

## symbols ##

Symbol(s::Symbol) = s
Symbol(s::ASCIIString) = Symbol(s.data)
Symbol(s::UTF8String) = Symbol(s.data)
Symbol(a::Array{UInt8,1}) =
ccall(:jl_symbol_n, Ref{Symbol}, (Ptr{UInt8}, Int32), a, length(a))
Symbol(x...) = Symbol(string(x...))

gensym() = ccall(:jl_gensym, Ref{Symbol}, ())

gensym(s::ASCIIString) = gensym(s.data)
Expand Down
3 changes: 3 additions & 0 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ include("refpointer.jl")
include("checked.jl")
importall .Checked

# vararg Symbol constructor
Symbol(x...) = Symbol(string(x...))

# array structures
include("abstractarray.jl")
include("subarray.jl")
Expand Down
2 changes: 1 addition & 1 deletion contrib/BBEditTextWrangler-julia.plist
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,6 @@
<string>svdvals!</string>
<string>svdvals</string>
<string>sylvester</string>
<string>symbol</string>
<string>symdiff!</string>
<string>symdiff</string>
<string>symlink</string>
Expand Down Expand Up @@ -1495,6 +1494,7 @@
<string>SubOrDArray</string>
<string>SubString</string>
<string>SVDDense</string>
<string>Symbol</string>
<string>Symmetric</string>
<string>SymTridiagonal</string>
<string>Sys</string>
Expand Down
5 changes: 2 additions & 3 deletions doc/manual/metaprogramming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,8 @@ used as one building-block of expressions:
julia> typeof(ans)
Symbol

:obj:`Symbol`\ s can also be created using :func:`symbol`, which takes any
number of arguments and creates a new symbol by concatenating their string
representations together:
The :obj:`Symbol` constructor takes any number of arguments and creates a
new symbol by concatenating their string representations together:

.. doctest::

Expand Down
8 changes: 4 additions & 4 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3870,11 +3870,11 @@ end
# issue #16096
module M16096
macro iter()
quote
@inline function foo(sub)
it = 1
quote
@inline function foo(sub)
it = 1
end
end
end
end
end
let ex = expand(:(@M16096.iter))
Expand Down

0 comments on commit 81bc6e7

Please sign in to comment.