diff --git a/base/LineEdit.jl b/base/LineEdit.jl index 3f15c4a8a5990..8b3ae98afcb0a 100644 --- a/base/LineEdit.jl +++ b/base/LineEdit.jl @@ -711,7 +711,7 @@ end # If we ever actually want to match \0 in input, this will have to be reworked function normalize_keymap(keymap::Dict) ret = Dict{Char,Any}() - direct_keys = filter((k,v) -> isa(v, Union(Function, Nothing)), keymap) + direct_keys = filter((k,v) -> isa(v, Union(Function, Void)), keymap) # first direct entries for key in keys(direct_keys) add_nested_key!(ret, key, keymap[key]) @@ -726,7 +726,7 @@ function normalize_keymap(keymap::Dict) end match_input(k::Function, s, cs) = (update_key_repeats(s, cs); return keymap_fcn(k, s, last(cs))) -match_input(k::Nothing, s, cs) = (s,p) -> return :ok +match_input(k::Void, s, cs) = (s,p) -> return :ok function match_input(keymap::Dict, s, cs=Char[]) c = read(terminal(s), Char) push!(cs, c) @@ -735,7 +735,7 @@ function match_input(keymap::Dict, s, cs=Char[]) return match_input(get(keymap, k, nothing), s, cs) end -keymap_fcn(f::Nothing, s, c) = (s, p) -> return :ok +keymap_fcn(f::Void, s, c) = (s, p) -> return :ok function keymap_fcn(f::Function, s, c::Char) return (s, p) -> begin r = f(s, p, c) diff --git a/base/REPLCompletions.jl b/base/REPLCompletions.jl index 360dad860063d..af2d146049afd 100644 --- a/base/REPLCompletions.jl +++ b/base/REPLCompletions.jl @@ -24,7 +24,7 @@ function complete_symbol(sym, ffunc) mod = context_module lookup_module = true - t = None + t = Union() for name in strs[1:(end-1)] s = symbol(name) if lookup_module diff --git a/base/abstractarray.jl b/base/abstractarray.jl index a663a5eab9d03..dc6f37a6ec8ab 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -200,7 +200,6 @@ function copy!(dest::AbstractArray, doffs::Integer, src::AbstractArray, soffs::I end copy(a::AbstractArray) = copy!(similar(a), a) -copy(a::AbstractArray{None}) = a # cannot be assigned into so is immutable function copy!{R,S}(B::AbstractMatrix{R}, ir_dest::Range{Int}, jr_dest::Range{Int}, A::AbstractMatrix{S}, ir_src::Range{Int}, jr_src::Range{Int}) if length(ir_dest) != length(ir_src) || length(jr_dest) != length(jr_src) @@ -502,14 +501,14 @@ get(A::AbstractArray, I::RangeVecIntList, default) = get!(similar(A, typeof(defa ## Concatenation ## -promote_eltype() = None +promote_eltype() = Bottom promote_eltype(v1, vs...) = promote_type(eltype(v1), promote_eltype(vs...)) #TODO: ERROR CHECK -cat(catdim::Integer) = Array(None, 0) +cat(catdim::Integer) = Array(Bottom, 0) -vcat() = Array(None, 0) -hcat() = Array(None, 0) +vcat() = Array(Bottom, 0) +hcat() = Array(Bottom, 0) ## cat: special cases hcat{T}(X::T...) = T[ X[j] for i=1, j=1:length(X) ] @@ -518,7 +517,7 @@ vcat{T}(X::T...) = T[ X[i] for i=1:length(X) ] vcat{T<:Number}(X::T...) = T[ X[i] for i=1:length(X) ] function vcat(X::Number...) - T = None + T = Bottom for x in X T = promote_type(T,typeof(x)) end @@ -526,7 +525,7 @@ function vcat(X::Number...) end function hcat(X::Number...) - T = None + T = Bottom for x in X T = promote_type(T,typeof(x)) end @@ -1287,7 +1286,7 @@ function promote_to!{T}(f::Callable, offs, dest::AbstractArray{T}, A::AbstractAr end function map_promote(f::Callable, A::AbstractArray) - if isempty(A); return similar(A, None); end + if isempty(A); return similar(A, Bottom); end first = f(A[1]) dest = similar(A, typeof(first)) dest[1] = first diff --git a/base/array.jl b/base/array.jl index 80d6cd5100326..e4adfea0efa49 100644 --- a/base/array.jl +++ b/base/array.jl @@ -450,7 +450,7 @@ const _grow_none_errmsg = "[] cannot grow. Instead, initialize the array with \"T[]\", where T is the desired element type." function push!{T}(a::Array{T,1}, item) - if is(T,None) + if is(T,Bottom) error(_grow_none_errmsg) end # convert first so we don't grow the array if the assignment won't work @@ -467,7 +467,7 @@ function push!(a::Array{Any,1}, item::ANY) end function append!{T}(a::Array{T,1}, items::AbstractVector) - if is(T,None) + if is(T,Bottom) error(_grow_none_errmsg) end n = length(items) @@ -477,7 +477,7 @@ function append!{T}(a::Array{T,1}, items::AbstractVector) end function prepend!{T}(a::Array{T,1}, items::AbstractVector) - if is(T,None) + if is(T,Bottom) error(_grow_none_errmsg) end n = length(items) @@ -518,7 +518,7 @@ function pop!(a::Vector) end function unshift!{T}(a::Array{T,1}, item) - if is(T,None) + if is(T,Bottom) error(_grow_none_errmsg) end item = convert(T, item) diff --git a/base/base.jl b/base/base.jl index 05b8c2a9e20ed..d9c3f498bf1d0 100644 --- a/base/base.jl +++ b/base/base.jl @@ -10,6 +10,8 @@ const NonTupleType = Union(DataType,UnionType,TypeConstructor) typealias Callable Union(Function,DataType) +const Bottom = Union() + convert(T, x) = convert_default(T, x, convert) convert(::(), ::()) = () @@ -31,13 +33,6 @@ ptr_arg_convert(::Type{Ptr{Void}}, x) = x # conversion used by ccall cconvert(T, x) = convert(T, x) -# the following 3 definitions implement a 0.3 deprecation -cconvert{T}(::Type{Ptr{T}}, x::Array{T}) = convert(Ptr{T}, x) -cconvert(::Type{Ptr{None}}, x::Array) = convert(Ptr{None}, x) -function cconvert{T}(::Type{Ptr{T}}, x::Array) - depwarn("ccall Ptr argument types must now match exactly, or be Ptr{Void}.", :cconvert) - convert(Ptr{T}, pointer(x)) -end # use the code in ccall.cpp to safely allocate temporary pointer arrays cconvert{T}(::Type{Ptr{Ptr{T}}}, a::Array) = a # convert strings to ByteString to pass as pointers diff --git a/base/boot.jl b/base/boot.jl index d054fad583e06..8a39c61e0d481 100644 --- a/base/boot.jl +++ b/base/boot.jl @@ -32,8 +32,6 @@ # types::Tuple #end -#None = Union() - #type TypeVar # name::Symbol # lb::Type @@ -45,6 +43,10 @@ # body #end +#immutable Void +#end +#const nothing = Void() + #abstract AbstractArray{T,N} #abstract DenseArray{T,N} <: AbstractArray{T,N} @@ -115,12 +117,12 @@ import Core.Intrinsics.ccall export # key types - Any, DataType, Vararg, ANY, NTuple, None, Top, + Any, DataType, Vararg, ANY, NTuple, Top, Tuple, Type, TypeConstructor, TypeName, TypeVar, Union, UnionType, Void, AbstractArray, DenseArray, # special objects Box, Function, IntrinsicFunction, LambdaStaticData, Method, MethodTable, - Module, Nothing, Symbol, Task, Array, + Module, Symbol, Task, Array, # numeric types Bool, FloatingPoint, Float16, Float32, Float64, Number, Integer, Int, Int8, Int16, Int32, Int64, Int128, Ptr, Real, Signed, Uint, Uint8, Uint16, Uint32, @@ -164,9 +166,6 @@ export #ule_int, ult_int, unbox, urem_int, xor_int, sext_int, zext_int -immutable Nothing; end -const nothing = Nothing() - const (===) = is abstract Number diff --git a/base/cartesian.jl b/base/cartesian.jl index f8d39f78af59d..b376365678387 100644 --- a/base/cartesian.jl +++ b/base/cartesian.jl @@ -152,7 +152,7 @@ function get_splatinfo(ex::Expr, itersym::Symbol) end end end - "", Nothing + "", Void end # Replace splatted with desplatted for a specific number of arguments diff --git a/base/deprecated.jl b/base/deprecated.jl index 357b6dbe3737c..466e270d5b389 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -38,7 +38,7 @@ function depwarn(msg, funcsym) warn(msg, once=(caller!=C_NULL), key=caller, bt=bt) end -function firstcaller(bt::Array{Ptr{None},1}, funcsym::Symbol) +function firstcaller(bt::Array{Ptr{Void},1}, funcsym::Symbol) # Identify the calling line i = 1 while i <= length(bt) @@ -179,3 +179,9 @@ const IpAddr = IPAddr @deprecate isblank(s::String) all(c -> c == ' ' || c == '\t', s) @deprecate randbool! rand! + +export Nothing +const Nothing = Void + +export None +const None = Union() diff --git a/base/error.jl b/base/error.jl index d5007eb558757..8f502e03b68ca 100644 --- a/base/error.jl +++ b/base/error.jl @@ -25,8 +25,8 @@ macro unexpected() :(error("unexpected branch reached")) end -rethrow() = ccall(:jl_rethrow, Void, ())::None -rethrow(e) = ccall(:jl_rethrow_other, Void, (Any,), e)::None +rethrow() = ccall(:jl_rethrow, Void, ())::Bottom +rethrow(e) = ccall(:jl_rethrow_other, Void, (Any,), e)::Bottom backtrace() = ccall(:jl_backtrace_from_here, Array{Ptr{Void},1}, ()) catch_backtrace() = ccall(:jl_get_backtrace, Array{Ptr{Void},1}, ()) diff --git a/base/expr.jl b/base/expr.jl index 66db044c240aa..0f716b7d928e1 100644 --- a/base/expr.jl +++ b/base/expr.jl @@ -43,7 +43,7 @@ astcopy(x) = x ==(x::QuoteNode, y::QuoteNode) = x.value == y.value function show(io::IO, tv::TypeVar) - if !is(tv.lb, None) + if !is(tv.lb, Bottom) show(io, tv.lb) print(io, "<:") end diff --git a/base/inference.jl b/base/inference.jl index c02a7a713a854..0ecb096029962 100644 --- a/base/inference.jl +++ b/base/inference.jl @@ -29,7 +29,7 @@ type CallStack prev::Union(EmptyCallStack,CallStack) sv::StaticVarInfo - CallStack(ast, mod, types, prev) = new(ast, mod, types, false, 0, None, prev) + CallStack(ast, mod, types, prev) = new(ast, mod, types, false, 0, Bottom, prev) end inference_stack = EmptyCallStack() @@ -89,7 +89,7 @@ isvarargtype(t::ANY) = isa(t,DataType)&&is((t::DataType).name,Vararg.name) const t_func = ObjectIdDict() #t_func[tuple] = (0, Inf, (args...)->limit_tuple_depth(args)) -t_func[throw] = (1, 1, x->None) +t_func[throw] = (1, 1, x->Bottom) t_func[box] = (2, 2, (t,v)->(isType(t) ? t.parameters[1] : Any)) t_func[eq_int] = (2, 2, cmp_tfunc) t_func[ne_int] = (2, 2, cmp_tfunc) @@ -115,17 +115,15 @@ t_func[fpiseq] = (2, 2, cmp_tfunc) t_func[fpislt] = (2, 2, cmp_tfunc) t_func[nan_dom_err] = (2, 2, (a, b)->a) t_func[eval(Core.Intrinsics,:ccall)] = - (3, Inf, (fptr, rt, at, a...)->(is(rt,Type{Void}) ? Nothing : - isType(rt) ? rt.parameters[1] : Any)) + (3, Inf, (fptr, rt, at, a...)->(isType(rt) ? rt.parameters[1] : Any)) t_func[eval(Core.Intrinsics,:llvmcall)] = - (3, Inf, (fptr, rt, at, a...)->(is(rt,Type{Void}) ? Nothing : - isType(rt) ? rt.parameters[1] : + (3, Inf, (fptr, rt, at, a...)->(isType(rt) ? rt.parameters[1] : isa(rt,Tuple) ? map(x->x.parameters[1],rt) : Any)) t_func[eval(Core.Intrinsics,:cglobal)] = (1, 2, (fptr, t...)->(isempty(t) ? Ptr{Void} : isType(t[1]) ? Ptr{t[1].parameters[1]} : Ptr)) t_func[eval(Core.Intrinsics,:select_value)] = - # TODO: return None if cnd is definitely not a Bool + # TODO: return Bottom if cnd is definitely not a Bool (3, 3, (cnd, x, y)->Union(x,y)) t_func[is] = (2, 2, cmp_tfunc) t_func[issubtype] = (2, 2, cmp_tfunc) @@ -225,7 +223,7 @@ const tupleref_tfunc = function (A, t, i) return Any end if is(t,()) - return None + return Bottom end n = length(t) last = tupleref(t,n) @@ -237,12 +235,12 @@ const tupleref_tfunc = function (A, t, i) if vararg T = last.parameters[1] else - return None + return Bottom end elseif i == n && vararg T = last.parameters[1] elseif i <= 0 - return None + return Bottom else T = tupleref(t,i) end @@ -256,7 +254,7 @@ const tupleref_tfunc = function (A, t, i) if !isa(types, Type) return Any end - T = reduce(tmerge, None, types) + T = reduce(tmerge, Bottom, types) if wrapType return isleaftype(T) || isa(T,TypeVar) ? Type{T} : Type{TypeVar(:_,T)} else @@ -288,7 +286,7 @@ function limit_type_depth(t::ANY, d::Int, cov::Bool, vars) end end elseif isa(t,UnionType) - t === None && return t + t === Bottom && return t if d > MAX_TYPE_DEPTH R = Any else @@ -334,7 +332,7 @@ const getfield_tfunc = function (A, s0, name) end end if isa(s,UnionType) - return reduce(tmerge, None, map(t->getfield_tfunc(A, t, name), s.types)) + return reduce(tmerge, Bottom, map(t->getfield_tfunc(A, t, name), s.types)) end if !isa(s,DataType) || s.abstract return Any @@ -373,18 +371,18 @@ const getfield_tfunc = function (A, s0, name) end end end - return None + return Bottom elseif isa(A[2],Int) if isa(A[1],Module) || s === Module - return None + return Bottom end i::Int = A[2] if i < 1 || i > length(s.names) - return None + return Bottom end return s.types[i] else - return reduce(tmerge, None, s.types)#Union(s.types...) + return reduce(tmerge, Bottom, s.types)#Union(s.types...) end end t_func[getfield] = (2, 2, getfield_tfunc) @@ -400,7 +398,7 @@ const fieldtype_tfunc = function (A, s, name) return Type end t = getfield_tfunc(A, s, name) - if is(t,None) + if is(t,Bottom) return t end Type{isleaftype(t) || isa(t,TypeVar) ? t : TypeVar(:_, t)} @@ -455,7 +453,7 @@ const apply_type_tfunc = function (A, args...) end if i-1 > length(headtype.parameters) # too many parameters for type - return None + return Bottom end uncertain = true tparams = tuple(tparams..., headtype.parameters[i-1]) @@ -498,7 +496,7 @@ function builtin_tfunction(f::ANY, args::ANY, argtypes::ANY) return tuple_tfunc(argtypes, true) elseif is(f,arrayset) if length(argtypes) < 3 && !isva - return None + return Bottom end a1 = argtypes[1] if isvarargtype(a1) @@ -507,14 +505,14 @@ function builtin_tfunction(f::ANY, args::ANY, argtypes::ANY) return a1 elseif is(f,arrayref) if length(argtypes) < 2 && !isva - return None + return Bottom end a = argtypes[1] return (isa(a,DataType) && a<:Array ? a.parameters[1] : Any) elseif is(f,Expr) if length(argtypes) < 1 && !isva - return None + return Bottom end return Expr end @@ -536,7 +534,7 @@ function builtin_tfunction(f::ANY, args::ANY, argtypes::ANY) end elseif !(tf[1] <= length(argtypes) <= tf[2]) # wrong # of args - return None + return Bottom end if is(f,typeassert) || is(f,tupleref) || is(f,getfield) || is(f,apply_type) || is(f,fieldtype) @@ -627,7 +625,7 @@ const limit_tuple_type_n = function (t::Tuple, lim::Int) last = last.parameters[1] end tail = tuple(t[lim:(n-1)]..., last) - tail = typeintersect(reduce(tmerge, None, tail), Any) + tail = typeintersect(reduce(tmerge, Bottom, tail), Any) return tuple(t[1:(lim-1)]..., Vararg{tail}) end return t @@ -684,11 +682,11 @@ function abstract_call_gf(f, fargs, argtypes, e) # typically, considering many methods means spending lots of time # obtaining poor type information. # It is important for N to be >= the number of methods in the error() - # function, so we can still know that error() is always None. + # function, so we can still know that error() is always Bottom. # here I picked 4. argtypes = limit_tuple_type(argtypes) applicable = _methods(f, argtypes, 4) - rettype = None + rettype = Bottom if is(applicable,false) # this means too many methods matched isa(e,Expr) && (e.head = :call) @@ -697,7 +695,7 @@ function abstract_call_gf(f, fargs, argtypes, e) x::Array{Any,1} = applicable if isempty(x) # no methods match - # TODO: it would be nice to return None here, but during bootstrap we + # TODO: it would be nice to return Bottom here, but during bootstrap we # often compile code that calls methods not defined yet, so it is much # safer just to fall back on dynamic dispatch. return Any @@ -747,15 +745,15 @@ function abstract_call_gf(f, fargs, argtypes, e) break end end - # if rettype is None we've found a method not found error + # if rettype is Bottom we've found a method not found error #print("=> ", rettype, "\n") return rettype end function invoke_tfunc(f, types, argtypes) argtypes = typeintersect(types,limit_tuple_type(argtypes)) - if is(argtypes,None) - return None + if is(argtypes,Bottom) + return Bottom end applicable = _methods(f, types, -1) if isempty(applicable) @@ -862,7 +860,7 @@ function abstract_call(f, fargs, argtypes, vtypes, sv::StaticVarInfo, e) end if is(f,kwcall) if length(argtypes) < 3 - return None + return Bottom end if length(fargs) < 2 return Any @@ -890,7 +888,7 @@ function abstract_eval_arg(a::ANY, vtypes::ANY, sv::StaticVarInfo) if isa(a,Symbol) || isa(a,SymbolNode) t = typeintersect(t,Any) # remove Undef end - if isa(t,TypeVar) && t.lb == None && isleaftype(t.ub) + if isa(t,TypeVar) && t.lb == Bottom && isleaftype(t.ub) t = t.ub end return t @@ -899,8 +897,8 @@ end function abstract_eval_call(e, vtypes, sv::StaticVarInfo) fargs = e.args[2:end] argtypes = tuple([abstract_eval_arg(a, vtypes, sv) for a in fargs]...) - if any(x->is(x,None), argtypes) - return None + if any(x->is(x,Bottom), argtypes) + return Bottom end called = e.args[1] func = isconstantfunc(called, sv) @@ -957,7 +955,7 @@ function abstract_eval(e::ANY, vtypes, sv::StaticVarInfo) if is(e.head,:call) || is(e.head,:call1) t = abstract_eval_call(e, vtypes, sv) elseif is(e.head,:null) - t = Nothing + t = Void elseif is(e.head,:new) t = abstract_eval(e.args[1], vtypes, sv) if isType(t) @@ -979,12 +977,12 @@ function abstract_eval(e::ANY, vtypes, sv::StaticVarInfo) # remove unnecessary typevars t = t.name.primary end - if is(t,None) && Undef<:t0 + if is(t,Bottom) && Undef<:t0 # the first time we see this statement the variable will probably - # be Undef; return None so this doesn't contribute to the type + # be Undef; return Bottom so this doesn't contribute to the type # we eventually pick. - elseif is(t,None) - t = Type{None} + elseif is(t,Bottom) + t = Type{Bottom} elseif isleaftype(t) t = Type{t} elseif isleaftype(inference_stack.types) @@ -1013,7 +1011,7 @@ function abstract_eval(e::ANY, vtypes, sv::StaticVarInfo) else t = Any end - if isa(t,TypeVar) && t.lb === None + if isa(t,TypeVar) && t.lb === Bottom # no need to use a typevar as the type of an expression t = t.ub end @@ -1037,9 +1035,9 @@ function abstract_eval_constant(x::ANY) end # Undef is the static type of a value location (e.g. variable) that is -# undefined. The corresponding run-time type is None, since accessing an +# undefined. The corresponding run-time type is Bottom, since accessing an # undefined location is an error. A non-lvalue expression cannot have -# type Undef, only None. +# type Undef, only Bottom. # typealias Top Union(Any,Undef) abstract_eval_global(s::Symbol) = @@ -1255,7 +1253,7 @@ function typeinf(linfo::LambdaStaticData,atypes::Tuple,sparams::Tuple, def, cop) #dbg = #dotrace = true local ast::Expr, tfunc_idx - curtype = None + curtype = Bottom redo = false # check cached t-functions tf = def.tfunc @@ -1669,7 +1667,7 @@ function eval_annotate(e::ANY, vtypes::ANY, sv::StaticVarInfo, decls, clo) e.args[2] = eval_annotate(e.args[2], vtypes, sv, decls, clo) # TODO: if this def does not reach any uses, maybe don't do this rhstype = exprtype(e.args[2]) - if !is(rhstype,None) + if !is(rhstype,Bottom) record_var_type(s, rhstype, decls) end return e @@ -2309,7 +2307,7 @@ function inlineable(f, e::Expr, atypes, sv, enclosing_ast) icall = LabelNode(label_counter(body.args)+1) partmatch = Expr(:gotoifnot, false, icall.label) thrw = Expr(:call, :throw, Expr(:call, Main.Base.MethodError, (f, :inline), t)) - thrw.typ = None + thrw.typ = Bottom end for i=na:-1:1 # stmts_free needs to be calculated in reverse-argument order @@ -2413,7 +2411,7 @@ function inlineable(f, e::Expr, atypes, sv, enclosing_ast) end end free = effect_free(aei,sv,true) - if ((occ==0 && is(aeitype,None)) || islocal || (occ > 1 && !inline_worthy(aei, occ*2)) || + if ((occ==0 && is(aeitype,Bottom)) || islocal || (occ > 1 && !inline_worthy(aei, occ*2)) || (affect_free && !free) || (!affect_free && !effect_free(aei,sv,false))) if occ != 0 # islocal=true is implied by occ!=0 vnew = unique_name(enclosing_ast, ast) diff --git a/base/loading.jl b/base/loading.jl index f45b1ae4171bc..760370c512e5a 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -99,7 +99,7 @@ include_string(txt::String, fname::String) = include_string(txt::String) = include_string(txt, "string") -function source_path(default::Union(String,Nothing)="") +function source_path(default::Union(String,Void)="") t = current_task() while true s = t.storage diff --git a/base/methodshow.jl b/base/methodshow.jl index 6ba1e201d5ea1..e591b24a2d4a9 100644 --- a/base/methodshow.jl +++ b/base/methodshow.jl @@ -12,7 +12,7 @@ function argtype_decl(n, t) # -> (argname, argtype) if t === Any && !isempty(s) return s, "" end - if t <: Vararg && t !== None && t.parameters[1] === Any + if t <: Vararg && t !== Union() && t.parameters[1] === Any return string(s, "..."), "" end return s, string(t) diff --git a/base/multidimensional.jl b/base/multidimensional.jl index 3c1f0238fd638..4a6f6c22276cf 100644 --- a/base/multidimensional.jl +++ b/base/multidimensional.jl @@ -1,6 +1,6 @@ ### From array.jl -@ngenerate N Nothing function checksize(A::AbstractArray, I::NTuple{N, Any}...) +@ngenerate N Void function checksize(A::AbstractArray, I::NTuple{N, Any}...) @nexprs N d->(size(A, d) == length(I_d) || throw(DimensionMismatch("index $d has length $(length(I_d)), but size(A, $d) = $(size(A,d))"))) nothing end diff --git a/base/pkg/github.jl b/base/pkg/github.jl index 8b6bcef435a23..cc32239a366f2 100644 --- a/base/pkg/github.jl +++ b/base/pkg/github.jl @@ -47,7 +47,7 @@ function curl(url::String, opts::Cmd=``) end error("strangely formatted HTTP response") end -curl(url::String, data::Nothing, opts::Cmd=``) = curl(url,opts) +curl(url::String, data::Void, opts::Cmd=``) = curl(url,opts) curl(url::String, data, opts::Cmd=``) = curl(url,`--data $(sprint(io->json().print(io,data))) $opts`) diff --git a/base/pkg/query.jl b/base/pkg/query.jl index b908e365b0cef..ad0cfe8e119c8 100644 --- a/base/pkg/query.jl +++ b/base/pkg/query.jl @@ -64,7 +64,7 @@ function dependencies(avail::Dict, fix::Dict = (ByteString=>Fixed)["julia"=>Fixe avail, conflicts end -typealias PackageState Union(Nothing,VersionNumber) +typealias PackageState Union(Void,VersionNumber) function diff(have::Dict, want::Dict, avail::Dict, fixed::Dict) change = Array((ByteString,(PackageState,PackageState)),0) diff --git a/base/pointer.jl b/base/pointer.jl index 654a896e004a6..78a8370938ffd 100644 --- a/base/pointer.jl +++ b/base/pointer.jl @@ -20,7 +20,7 @@ convert(::Type{Ptr{Uint8}}, s::ByteString) = convert(Ptr{Uint8}, s.data) convert(::Type{Ptr{Int8}}, s::ByteString) = convert(Ptr{Int8}, s.data) convert{T}(::Type{Ptr{T}}, a::Array{T}) = ccall(:jl_array_ptr, Ptr{T}, (Any,), a) -convert(::Type{Ptr{None}}, a::Array) = ccall(:jl_array_ptr, Ptr{None}, (Any,), a) +convert(::Type{Ptr{Void}}, a::Array) = ccall(:jl_array_ptr, Ptr{Void}, (Any,), a) # note: these definitions don't mean any AbstractArray is convertible to # pointer. they just map the array element type to the pointer type for diff --git a/base/precompile.jl b/base/precompile.jl index 4dd248140a678..2166388c89f71 100644 --- a/base/precompile.jl +++ b/base/precompile.jl @@ -87,7 +87,7 @@ precompile(abstract_interpret, (Bool, ObjectIdDict, StaticVarInfo)) precompile(eval_annotate, (LambdaStaticData, ObjectIdDict, StaticVarInfo, ObjectIdDict, Array{Any,1})) precompile(occurs_more, (Bool, Function, Int)) precompile(isconstantfunc, (SymbolNode, StaticVarInfo)) -precompile(CallStack, (Expr, Module, (Nothing,), EmptyCallStack)) +precompile(CallStack, (Expr, Module, (Void,), EmptyCallStack)) precompile(convert, (Type{Module}, Module)) precompile(effect_free, (Expr,)) precompile(effect_free, (TopNode,)) @@ -125,7 +125,7 @@ precompile(==, (Bool,Bool)) precompile(try_include, (ASCIIString,)) precompile(isfile, (ASCIIString,)) precompile(include_from_node1, (ASCIIString,)) -precompile(source_path, (Nothing,)) +precompile(source_path, (Void,)) precompile(task_local_storage, ()) precompile(atexit, (Function,)) precompile(print, (TTY, ASCIIString)) @@ -156,7 +156,7 @@ precompile(!=, (SubString{ASCIIString}, ASCIIString)) precompile(print_joined, (IOBuffer, Array{SubString{ASCIIString}, 1}, ASCIIString)) precompile(push!, (Array{Union(ASCIIString, UTF8String), 1}, ASCIIString)) precompile(Terminals.TTYTerminal, (ASCIIString, TTY, TTY, TTY)) -precompile(isequal, (Nothing, Nothing)) +precompile(isequal, (Void, Void)) precompile(banner, (Terminals.TTYTerminal, Terminals.TTYTerminal)) precompile(banner, (Terminals.TTYTerminal,)) precompile(print, (IOBuffer, VersionNumber)) @@ -220,7 +220,7 @@ precompile(keys, (Dict{Uint8, Any},)) precompile(in, (Uint8, KeyIterator{Dict{Uint8, Any}})) precompile(ht_keyindex, (Dict{Uint8, Any}, Uint8)) precompile(push!, (Array{String, 1}, ASCIIString)) -precompile(LineEdit.fix_conflicts!, (Nothing, Int)) +precompile(LineEdit.fix_conflicts!, (Void, Int)) precompile(convert, (Type{Function}, Function)) precompile(convert, (Type{Any}, Function)) precompile(similar, (Array{LineEdit.Prompt, 1}, Type{LineEdit.TextInterface}, (Int,))) diff --git a/base/process.jl b/base/process.jl index 261074142a2d7..28cb13e1ceb6a 100644 --- a/base/process.jl +++ b/base/process.jl @@ -4,7 +4,7 @@ type Cmd <: AbstractCmd exec::Vector{ByteString} ignorestatus::Bool detach::Bool - env::Union(Array{ByteString},Nothing) + env::Union(Array{ByteString},Void) dir::UTF8String Cmd(exec::Vector{ByteString}) = new(exec, false, false, nothing, "") end diff --git a/base/profile.jl b/base/profile.jl index b3676606526d0..9f2a5a8bfd8ec 100644 --- a/base/profile.jl +++ b/base/profile.jl @@ -21,7 +21,7 @@ end #### #### User-level functions #### -function init(; n::Union(Nothing,Integer) = nothing, delay::Union(Nothing,Float64) = nothing) +function init(; n::Union(Void,Integer) = nothing, delay::Union(Void,Float64) = nothing) n_cur = ccall(:jl_profile_maxlen_data, Csize_t, ()) delay_cur = ccall(:jl_profile_delay_nsec, Uint64, ())/10^9 if n == nothing && delay == nothing diff --git a/base/promotion.jl b/base/promotion.jl index a3879cd1cb311..5e5395402ba1e 100644 --- a/base/promotion.jl +++ b/base/promotion.jl @@ -1,6 +1,6 @@ ## type join (closest common ancestor, or least upper bound) ## -typejoin() = None +typejoin() = Bottom typejoin(t::ANY) = t typejoin(t::ANY, ts...) = typejoin(t, typejoin(ts...)) function typejoin(a::ANY, b::ANY) @@ -22,7 +22,7 @@ function typejoin(a::ANY, b::ANY) if !isa(u,UnionType) return u end - return reduce(typejoin, None, u.types) + return reduce(typejoin, Bottom, u.types) end if isa(a,Tuple) if !isa(b,Tuple) @@ -82,7 +82,7 @@ end # reduce typejoin over tup[i:end] function tailjoin(tup, i) - t = None + t = Bottom for j = i:length(tup) tj = tup[j] t = typejoin(t, isvarargtype(tj)?tj.parameters[1]:tj) @@ -92,30 +92,30 @@ end ## promotion mechanism ## -promote_type() = None +promote_type() = Bottom promote_type(T) = T promote_type(T, S ) = typejoin(T, S) promote_type(T, S...) = promote_type(T, promote_type(S...)) -promote_type(::Type{None}, ::Type{None}) = None +promote_type(::Type{Bottom}, ::Type{Bottom}) = Bottom promote_type{T}(::Type{T}, ::Type{T}) = T -promote_type{T}(::Type{T}, ::Type{None}) = T -promote_type{T}(::Type{None}, ::Type{T}) = T +promote_type{T}(::Type{T}, ::Type{Bottom}) = T +promote_type{T}(::Type{Bottom}, ::Type{T}) = T # Try promote_rule in both orders. Typically only one is defined, -# and there is a fallback returning None below, so the common case is +# and there is a fallback returning Bottom below, so the common case is # promote_type(T, S) => -# promote_result(T, S, result, None) => -# typejoin(result, None) => result +# promote_result(T, S, result, Bottom) => +# typejoin(result, Bottom) => result promote_type{T,S}(::Type{T}, ::Type{S}) = promote_result(T, S, promote_rule(T,S), promote_rule(S,T)) -promote_rule(T, S) = None +promote_rule(T, S) = Bottom promote_result(t,s,T,S) = promote_type(T,S) -# If no promote_rule is defined, both directions give None. In that +# If no promote_rule is defined, both directions give Bottom. In that # case use typejoin on the original types instead. -promote_result{T,S}(::Type{T},::Type{S},::Type{None},::Type{None}) = typejoin(T, S) +promote_result{T,S}(::Type{T},::Type{S},::Type{Bottom},::Type{Bottom}) = typejoin(T, S) promote() = () promote(x) = (x,) @@ -143,7 +143,7 @@ end # Otherwise, typejoin(T,S) is called (returning Number) so no conversion # happens, and +(promote(x,y)...) is called again, causing a stack # overflow. -promote_result{T<:Number,S<:Number}(::Type{T},::Type{S},::Type{None},::Type{None}) = +promote_result{T<:Number,S<:Number}(::Type{T},::Type{S},::Type{Bottom},::Type{Bottom}) = promote_to_super(T, S, typejoin(T,S)) # promote numeric types T and S to typejoin(T,S) if T<:S or S<:T diff --git a/base/reflection.jl b/base/reflection.jl index 5ce427b9f87b9..2317722a480ed 100644 --- a/base/reflection.jl +++ b/base/reflection.jl @@ -73,7 +73,7 @@ function _subtypes(m::Module, x::DataType, sts=Set(), visited=Set()) t = eval(m,s) if isa(t, DataType) && t.name.name == s && super(t).name == x.name ti = typeintersect(t, x) - ti != None && push!(sts, ti) + ti != Bottom && push!(sts, ti) elseif isa(t, Module) && !in(t, visited) _subtypes(t, x, sts, visited) end diff --git a/base/regex.jl b/base/regex.jl index 04d108fc77b4a..a71c07632b938 100644 --- a/base/regex.jl +++ b/base/regex.jl @@ -80,7 +80,7 @@ end immutable RegexMatch match::SubString{UTF8String} - captures::Vector{Union(Nothing,SubString{UTF8String})} + captures::Vector{Union(Void,SubString{UTF8String})} offset::Int offsets::Vector{Int} end @@ -121,7 +121,7 @@ function match(re::Regex, str::UTF8String, idx::Integer, add_opts::Uint32=uint32 end n = length(re.ovec)/3 - 1 mat = SubString(str, re.ovec[1]+1, re.ovec[2]) - cap = Union(Nothing,SubString{UTF8String})[ + cap = Union(Void,SubString{UTF8String})[ re.ovec[2i+1] < 0 ? nothing : SubString(str, re.ovec[2i+1]+1, re.ovec[2i+2]) for i=1:n ] off = Int[ re.ovec[2i+1]::Int32+1 for i=1:n ] RegexMatch(mat, cap, re.ovec[1]+1, off) diff --git a/base/serialize.jl b/base/serialize.jl index 48962ae7a38f5..5345cea80ab11 100644 --- a/base/serialize.jl +++ b/base/serialize.jl @@ -21,7 +21,7 @@ let i = 2 UTF16String, UTF32String, Float16, :reserved9, :reserved10, :reserved11, :reserved12, - (), Bool, Any, :Any, None, Top, Undef, Type, + (), Bool, Any, :Any, Bottom, Top, Undef, Type, :Array, :TypeVar, :Box, :lambda, :body, :return, :call, symbol("::"), :(=), :null, :gotoifnot, :A, :B, :C, :M, :N, :T, :S, :X, :Y, diff --git a/base/set.jl b/base/set.jl index b7a9a474707a2..abc2a9a7cef74 100644 --- a/base/set.jl +++ b/base/set.jl @@ -1,8 +1,8 @@ type Set{T} - dict::Dict{T,Nothing} + dict::Dict{T,Void} - Set() = new(Dict{T,Nothing}()) - Set(itr) = union!(new(Dict{T,Nothing}()), itr) + Set() = new(Dict{T,Void}()) + Set(itr) = union!(new(Dict{T,Void}()), itr) end Set() = Set{Any}() Set(itr) = Set{eltype(itr)}(itr) @@ -37,7 +37,7 @@ next(s::Set, i) = (s.dict.keys[i], skip_deleted(s.dict,i+1)) # TODO: simplify me? pop!(s::Set) = (val = s.dict.keys[start(s.dict)]; delete!(s.dict, val); val) -join_eltype() = None +join_eltype() = Bottom join_eltype(v1, vs...) = typejoin(eltype(v1), join_eltype(vs...)) union() = Set() diff --git a/base/show.jl b/base/show.jl index c2963a4dfd905..cd2f426491eab 100644 --- a/base/show.jl +++ b/base/show.jl @@ -68,9 +68,7 @@ function show(io::IO, x::IntrinsicFunction) end function show(io::IO, x::UnionType) - if is(x,None) - print(io, "None") - elseif is(x,Top) + if is(x,Top) print(io, "Top") else print(io, "Union", x.types) @@ -107,14 +105,13 @@ macro show(exs...) end show(io::IO, tn::TypeName) = print(io, tn.name) -show(io::IO, ::Nothing) = print(io, "nothing") +show(io::IO, ::Void) = print(io, "nothing") show(io::IO, b::Bool) = print(io, b ? "true" : "false") show(io::IO, n::Signed) = (write(io, dec(n)); nothing) show(io::IO, n::Unsigned) = print(io, "0x", hex(n,sizeof(n)<<1)) print(io::IO, n::Unsigned) = print(io, dec(n)) -show{T}(io::IO, p::Ptr{T}) = - print(io, is(T,None) ? "Ptr{Void}" : typeof(p), " @0x$(hex(unsigned(p), WORD_SIZE>>2))") +show{T}(io::IO, p::Ptr{T}) = print(io, typeof(p), " @0x$(hex(unsigned(p), WORD_SIZE>>2))") function show(io::IO, m::Module) if is(m,Main) @@ -197,12 +194,6 @@ show_comma_array(io::IO, itr, o, c) = show_delim_array(io, itr, o, ',', c, false show(io::IO, t::Tuple) = show_delim_array(io, t, '(', ',', ')', true) show(io::IO, s::Symbol) = show_unquoted(io, QuoteNode(s)) -show(io::IO, tn::TypeName) = print(io, tn.name) -show(io::IO, ::Nothing) = print(io, "nothing") -show(io::IO, b::Bool) = print(io, b ? "true" : "false") -show(io::IO, n::Signed) = (write(io, dec(n)); nothing) -show(io::IO, n::Unsigned) = print(io, "0x", hex(n,sizeof(n)<<1)) -print(io::IO, n::Unsigned) = print(io, dec(n)) ## Abstract Syntax Tree (AST) printing ## diff --git a/base/sparse/csparse.jl b/base/sparse/csparse.jl index d3eb38c95c5d1..a22a3f9b98364 100644 --- a/base/sparse/csparse.jl +++ b/base/sparse/csparse.jl @@ -358,8 +358,8 @@ function fkeep!{Tv,Ti}(A::SparseMatrixCSC{Tv,Ti}, f, other) end droptol!(A::SparseMatrixCSC, tol) = fkeep!(A, (i,j,x,other)->abs(x)>other, tol) -dropzeros!(A::SparseMatrixCSC) = fkeep!(A, (i,j,x,other)->x!=0, None) -triu!(A::SparseMatrixCSC) = fkeep!(A, (i,j,x,other)->(j>=i), None) +dropzeros!(A::SparseMatrixCSC) = fkeep!(A, (i,j,x,other)->x!=0, nothing) +triu!(A::SparseMatrixCSC) = fkeep!(A, (i,j,x,other)->(j>=i), nothing) triu(A::SparseMatrixCSC) = triu!(copy(A)) -tril!(A::SparseMatrixCSC) = fkeep!(A, (i,j,x,other)->(i>=j), None) +tril!(A::SparseMatrixCSC) = fkeep!(A, (i,j,x,other)->(i>=j), nothing) tril(A::SparseMatrixCSC) = tril!(copy(A)) diff --git a/base/sparse/sparsematrix.jl b/base/sparse/sparsematrix.jl index b3e40799aef4a..e65a4353addf2 100644 --- a/base/sparse/sparsematrix.jl +++ b/base/sparse/sparsematrix.jl @@ -431,24 +431,24 @@ end # Operations that may map nonzeros to zero, and zero to zero # Result is sparse -for (op, restype) in ((:iceil, Int), (:ceil, Nothing), - (:ifloor, Int), (:floor, Nothing), - (:itrunc, Int), (:trunc, Nothing), - (:iround, Int), (:round, Nothing), - (:sin, Nothing), (:tan, Nothing), - (:sinh, Nothing), (:tanh, Nothing), - (:asin, Nothing), (:atan, Nothing), - (:asinh, Nothing), (:atanh, Nothing), - (:sinpi, Nothing), (:cosc, Nothing), - (:sind, Nothing), (:tand, Nothing), - (:asind, Nothing), (:atand, Nothing) ) +for (op, restype) in ((:iceil, Int), (:ceil, Void), + (:ifloor, Int), (:floor, Void), + (:itrunc, Int), (:trunc, Void), + (:iround, Int), (:round, Void), + (:sin, Void), (:tan, Void), + (:sinh, Void), (:tanh, Void), + (:asin, Void), (:atan, Void), + (:asinh, Void), (:atanh, Void), + (:sinpi, Void), (:cosc, Void), + (:sind, Void), (:tand, Void), + (:asind, Void), (:atand, Void) ) @eval begin function ($op){Tv,Ti}(A::SparseMatrixCSC{Tv,Ti}) nfilledA = nnz(A) colptrB = Array(Ti, A.n+1) rowvalB = Array(Ti, nfilledA) - nzvalB = Array($(restype==Nothing ? (:Tv) : restype), nfilledA) + nzvalB = Array($(restype==Void ? (:Tv) : restype), nfilledA) k = 0 # number of additional zeros introduced by op(A) @inbounds for i = 1 : A.n @@ -515,7 +515,7 @@ end ## Binary arithmetic and boolean operators -for (op, restype) in ( (:+, Nothing), (:-, Nothing), (:.*, Nothing), +for (op, restype) in ( (:+, Void), (:-, Void), (:.*, Void), (:(.<), Bool) ) @eval begin @@ -538,7 +538,7 @@ for (op, restype) in ( (:+, Nothing), (:-, Nothing), (:.*, Nothing), nnzS = nnz(A) + nnz(B) colptrS = Array(Ti, A.n+1) rowvalS = Array(Ti, nnzS) - nzvalS = Array($(restype==Nothing ? (:Tv) : restype), nnzS) + nzvalS = Array($(restype==Void ? (:Tv) : restype), nnzS) z = zero(Tv) diff --git a/base/subarray.jl b/base/subarray.jl index 9eaf962fa11a2..139ffb18850b7 100644 --- a/base/subarray.jl +++ b/base/subarray.jl @@ -400,7 +400,7 @@ stride(s::SubArray, i::Integer) = i <= length(s.strides) ? s.strides[i] : s.stri convert{T}(::Type{Ptr{T}}, x::SubArray{T}) = pointer(x.parent) + (x.first_index-1)*sizeof(T) -convert{T}(::Type{Ptr{None}}, x::SubArray{T}) = convert(Ptr{None}, convert(Ptr{T},x)) +convert{T}(::Type{Ptr{Void}}, x::SubArray{T}) = convert(Ptr{Void}, convert(Ptr{T},x)) convert{T,S,N}(::Type{Array{T,N}},A::SubArray{S,N}) = copy!(Array(T,size(A)), A) pointer(s::SubArray, i::Int) = pointer(s, ind2sub(size(s), i)) diff --git a/contrib/Julia_Notepad++.xml b/contrib/Julia_Notepad++.xml index 990e86ad50af8..7dbb125adb3b0 100644 --- a/contrib/Julia_Notepad++.xml +++ b/contrib/Julia_Notepad++.xml @@ -12,7 +12,7 @@ end "00"00 abstract bitstype break ccall const continue export global import importall in local macro module baremodule return typealias using - AbstractArray AbstractMatrix AbstractSparseMatrix AbstractVector Any Array ASCIIString Associative AsyncStream BitArray BigFloat BigInt BitMatrix BitVector Bool ByteString Char CharString Colon Complex Complex64 Complex128 ComplexPair DArray Dict Dims EachLine EnvHash Exception Expr FileOffset Filter Float Float32 Float64 Function ObjectIdDict Int Int8 Int16 Int32 Int64 Int128 Integer IntSet ImaginaryUnit IO IOBuffer IOStream LocalProcess Matrix Nothing None NTuple Number ObjectIdDict OrdinalRange PipeBuffer ProcessGroup Ptr Range Range1 RangeIndex Ranges Rational Real Regex RegexMatch RegexMatchIterator RemoteRef RepString RevString Reverse RopeString Set Signed SparseMatrixCSC SpawnNullStream StridedArray StridedMatrix StridedVecOrMat StridedVector String SubArray SubDArray SubOrDArray SubString Symbol SymTridiagonal Task TcpSocket Tridiagonal Tuple Type Uint Uint8 Uint16 Uint32 Uint64 Uint128 Union Unsigned UTF8String UVError VecOrMat Vector VersionNumber Void WeakKeyDict WeakRef Woodbury Zip Stat Factorization BunchKaufman CholeskyDense CholeskyPivotedDense LUDense LUTridiagonal LDLTTridiagonal QRDense QRPivotedDense SVDDense GSVDDense InsertionSort QuickSort MergeSort TimSort Cchar Cuchar Cshort Cushort Cint Cuint Clong Culong Cptrdiff_t Csize_t Clonglong Culonglong Cintmax_t Cuintmax_t Cfloat Cdouble ArgumentError DisconnectException EOFError ErrorException KeyError LoadError MethodError ParseError SystemError TypeError + AbstractArray AbstractMatrix AbstractSparseMatrix AbstractVector Any Array ASCIIString Associative AsyncStream BitArray BigFloat BigInt BitMatrix BitVector Bool ByteString Char CharString Colon Complex Complex64 Complex128 ComplexPair DArray Dict Dims EachLine EnvHash Exception Expr FileOffset Filter Float Float32 Float64 Function ObjectIdDict Int Int8 Int16 Int32 Int64 Int128 Integer IntSet ImaginaryUnit IO IOBuffer IOStream LocalProcess Matrix NTuple Number ObjectIdDict OrdinalRange PipeBuffer ProcessGroup Ptr Range Range1 RangeIndex Ranges Rational Real Regex RegexMatch RegexMatchIterator RemoteRef RepString RevString Reverse RopeString Set Signed SparseMatrixCSC SpawnNullStream StridedArray StridedMatrix StridedVecOrMat StridedVector String SubArray SubDArray SubOrDArray SubString Symbol SymTridiagonal Task TcpSocket Tridiagonal Tuple Type Uint Uint8 Uint16 Uint32 Uint64 Uint128 Union Unsigned UTF8String UVError VecOrMat Vector VersionNumber Void WeakKeyDict WeakRef Woodbury Zip Stat Factorization BunchKaufman CholeskyDense CholeskyPivotedDense LUDense LUTridiagonal LDLTTridiagonal QRDense QRPivotedDense SVDDense GSVDDense InsertionSort QuickSort MergeSort TimSort Cchar Cuchar Cshort Cushort Cint Cuint Clong Culong Cptrdiff_t Csize_t Clonglong Culonglong Cintmax_t Cuintmax_t Cfloat Cdouble ArgumentError DisconnectException EOFError ErrorException KeyError LoadError MethodError ParseError SystemError TypeError diff --git a/contrib/julia-mode.el b/contrib/julia-mode.el index 1ba68006108ed..59c14e040660e 100644 --- a/contrib/julia-mode.el +++ b/contrib/julia-mode.el @@ -145,7 +145,7 @@ (defconst julia-font-lock-keywords (list - '("\\<\\(\\|Uint\\(8\\|16\\|32\\|64\\|128\\)\\|Int\\(8\\|16\\|32\\|64\\|128\\)\\|BigInt\\|Integer\\|BigFloat\\|FloatingPoint\\|Float16\\|Float32\\|Float64\\|Complex128\\|Complex64\\|ComplexPair\\|Bool\\|Char\\|DataType\\|Number\\|Real\\|Int\\|Uint\\|Array\\|DArray\\|AbstractArray\\|AbstractVector\\|AbstractMatrix\\|AbstractSparseMatrix\\|SubArray\\|StridedArray\\|StridedVector\\|StridedMatrix\\|VecOrMat\\|StridedVecOrMat\\|DenseArray\\|Range\\|OrdinalRange\\|StepRange\\|UnitRange\\|FloatRange\\|SparseMatrixCSC\\|Tuple\\|NTuple\\|Symbol\\|Function\\|Vector\\|Matrix\\|Union\\|Type\\|Any\\|Complex\\|None\\|String\\|Ptr\\|Void\\|Exception\\|Task\\|Signed\\|Unsigned\\|Associative\\|Dict\\|IO\\|IOStream\\|Rational\\|Regex\\|RegexMatch\\|Set\\|IntSet\\|ASCIIString\\|UTF8String\\|ByteString\\|Expr\\|WeakRef\\|Nothing\\|ObjectIdDict\\|SubString\\)\\>" . + '("\\<\\(\\|Uint\\(8\\|16\\|32\\|64\\|128\\)\\|Int\\(8\\|16\\|32\\|64\\|128\\)\\|BigInt\\|Integer\\|BigFloat\\|FloatingPoint\\|Float16\\|Float32\\|Float64\\|Complex128\\|Complex64\\|ComplexPair\\|Bool\\|Char\\|DataType\\|Number\\|Real\\|Int\\|Uint\\|Array\\|DArray\\|AbstractArray\\|AbstractVector\\|AbstractMatrix\\|AbstractSparseMatrix\\|SubArray\\|StridedArray\\|StridedVector\\|StridedMatrix\\|VecOrMat\\|StridedVecOrMat\\|DenseArray\\|Range\\|OrdinalRange\\|StepRange\\|UnitRange\\|FloatRange\\|SparseMatrixCSC\\|Tuple\\|NTuple\\|Symbol\\|Function\\|Vector\\|Matrix\\|Union\\|Type\\|Any\\|Complex\\|String\\|Ptr\\|Void\\|Exception\\|Task\\|Signed\\|Unsigned\\|Associative\\|Dict\\|IO\\|IOStream\\|Rational\\|Regex\\|RegexMatch\\|Set\\|IntSet\\|ASCIIString\\|UTF8String\\|ByteString\\|Expr\\|WeakRef\\|ObjectIdDict\\|SubString\\)\\>" . font-lock-type-face) (cons julia-keyword-regex 'font-lock-keyword-face) (cons julia-macro-regex 'font-lock-keyword-face) diff --git a/contrib/julia.lang b/contrib/julia.lang index cd0730d86a281..56eb971640cd9 100644 --- a/contrib/julia.lang +++ b/contrib/julia.lang @@ -232,7 +232,7 @@ - Any|None|Nothing|Void + Any|Void Type(Constructor|Name|Var|_Array)?|(Union|Data|NonTuple)Type (Abstract|Strided|Bit)?(Array|Matrix|Vector) Abstract(Cmd|RNG|SparseMatrix) diff --git a/contrib/julia.xml b/contrib/julia.xml index 4f97dfa2199c5..4d538c2aa3376 100644 --- a/contrib/julia.xml +++ b/contrib/julia.xml @@ -142,8 +142,6 @@ LU MathConst Matrix - Nothing - None NTuple Number ObjectIdDict diff --git a/src/alloc.c b/src/alloc.c index 4db66e169ffde..df9392a775520 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -55,6 +55,7 @@ jl_datatype_t *jl_methoderror_type; jl_datatype_t *jl_loaderror_type; jl_datatype_t *jl_undefvarerror_type; jl_datatype_t *jl_pointer_type; +jl_datatype_t *jl_void_type; jl_datatype_t *jl_voidpointer_type; jl_value_t *jl_an_empty_cell=NULL; jl_value_t *jl_stackovf_exception; diff --git a/src/builtins.c b/src/builtins.c index a2b9fa767f331..03de05f1ff3a3 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -1058,9 +1058,9 @@ void jl_init_primitives(void) // builtin types add_builtin("Any", (jl_value_t*)jl_any_type); - add_builtin("None", (jl_value_t*)jl_bottom_type); - add_builtin("Void", (jl_value_t*)jl_bottom_type); add_builtin("Top", (jl_value_t*)jl_top_type); + add_builtin("Void", (jl_value_t*)jl_void_type); + add_builtin("nothing", (jl_value_t*)jl_nothing); add_builtin("TypeVar", (jl_value_t*)jl_tvar_type); add_builtin("TypeName", (jl_value_t*)jl_typename_type); add_builtin("TypeConstructor", (jl_value_t*)jl_typector_type); @@ -1223,12 +1223,12 @@ DLLEXPORT size_t jl_static_show(JL_STREAM *out, jl_value_t *v) else if (v == jl_false) { n += JL_PRINTF(out, "false"); } + else if (v == jl_nothing) { + n += JL_PRINTF(out, "nothing"); + } else if (jl_is_byte_string(v)) { n += JL_PRINTF(out, "\"%s\"", jl_iostr_data(v)); } - else if (v == jl_bottom_type) { - n += JL_PRINTF(out, "Void"); - } else if (jl_is_uniontype(v)) { n += JL_PRINTF(out, "Union"); n += jl_static_show(out, (jl_value_t*)((jl_uniontype_t*)v)->types); diff --git a/src/ccall.cpp b/src/ccall.cpp index c3543132a5fb2..ea32513241323 100644 --- a/src/ccall.cpp +++ b/src/ccall.cpp @@ -302,8 +302,10 @@ extern "C" DLLEXPORT void *jl_value_to_pointer(jl_value_t *jt, jl_value_t *v, in return jl_string_data(v); } if (jl_is_array_type(jvt)) { - if (jl_tparam0(jl_typeof(v)) == jt || jt==(jl_value_t*)jl_bottom_type) + if (jl_tparam0(jl_typeof(v)) == jt || jt == (jl_value_t*)jl_bottom_type || + jt == (jl_value_t*)jl_void_type) { return ((jl_array_t*)v)->data; + } if (jl_is_cpointer_type(jt)) { jl_array_t *ar = (jl_array_t*)v; void **temp=(void**)alloc_temp_arg_space((1+jl_array_len(ar))*sizeof(void*)); @@ -375,8 +377,8 @@ static Value *julia_to_native(Type *ty, jl_value_t *jt, Value *jv, assert(ty->isPointerTy()); jl_value_t *aty = expr_type(argex, ctx); if (jl_is_array_type(aty) && - (jl_tparam0(jt) == jl_tparam0(aty) || - jl_tparam0(jt) == (jl_value_t*)jl_bottom_type)) { + (jl_tparam0(jt) == jl_tparam0(aty) || jl_tparam0(jt) == (jl_value_t*)jl_bottom_type || + jl_tparam0(jt) == (jl_value_t*)jl_void_type)) { // array to pointer return builder.CreateBitCast(emit_arrayptr(jv), ty); } diff --git a/src/cgutils.cpp b/src/cgutils.cpp index 2cc42fa855c28..62a887481741e 100644 --- a/src/cgutils.cpp +++ b/src/cgutils.cpp @@ -529,8 +529,8 @@ static jl_value_t *llvm_type_to_julia(Type *t, bool throw_error) if (t == T_int64) return (jl_value_t*)jl_int64_type; if (t == T_float32) return (jl_value_t*)jl_float32_type; if (t == T_float64) return (jl_value_t*)jl_float64_type; - if (t == T_void) return (jl_value_t*)jl_bottom_type; - if (t->isEmptyTy()) return (jl_value_t*)jl_nothing->type; + if (t == T_void) return (jl_value_t*)jl_void_type; + if (t->isEmptyTy()) return (jl_value_t*)jl_void_type; if (t == jl_pvalue_llvmt) return (jl_value_t*)jl_any_type; if (t->isPointerTy()) { @@ -1457,7 +1457,7 @@ static jl_value_t *static_void_instance(jl_value_t *jt) //assert(jb->instance != NULL); return (jl_value_t*)jb->instance; } - else if (jt == jl_typeof(jl_nothing) || jt == jl_bottom_type) { + else if (jt == (jl_value_t*)jl_void_type) { return (jl_value_t*)jl_nothing; } assert(jl_is_tuple(jt)); @@ -1541,8 +1541,10 @@ static Value *boxed(Value *v, jl_codectx_t *ctx, jl_value_t *jt) if (jl_subtype(jt2, jt, 0)) jt = jt2; } + if (jt == jl_bottom_type) + return UndefValue::get(jl_pvalue_llvmt); UndefValue *uv = NULL; - if (jt == jl_bottom_type || v == NULL || (uv = dyn_cast(v)) != 0 || t == NoopType) { + if (v == NULL || (uv = dyn_cast(v)) != 0 || t == NoopType) { if (uv != NULL && jl_is_datatype(jt)) { jl_datatype_t *jb = (jl_datatype_t*)jt; // We have an undef value on a hopefully dead branch diff --git a/src/codegen.cpp b/src/codegen.cpp index 923aeb505ed4a..5c06649be6839 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -718,8 +718,7 @@ static Function *jl_cfunction_object(jl_function_t *f, jl_value_t *rt, jl_value_ } JL_TYPECHK(jl_function_ptr, tuple, argt); JL_TYPECHK(jl_function_ptr, type, argt); - if (jl_is_gf(f) && (rt == NULL || jl_is_leaf_type(rt) || rt == (jl_value_t*)jl_bottom_type) && - jl_is_leaf_type(argt)) { + if (jl_is_gf(f) && (rt == NULL || jl_is_leaf_type(rt)) && jl_is_leaf_type(argt)) { jl_function_t *ff = jl_get_specialization(f, (jl_tuple_t*)argt); if (ff != NULL && ff->env==(jl_value_t*)jl_null && ff->linfo != NULL) { if (ff->linfo->cFunctionObject == NULL) { @@ -733,8 +732,7 @@ static Function *jl_cfunction_object(jl_function_t *f, jl_value_t *rt, jl_value_ } if (rt != NULL) { jl_value_t *astrt = jl_ast_rettype(li, li->ast); - if (!jl_types_equal(astrt, rt) && - !(astrt==(jl_value_t*)jl_nothing->type && rt==(jl_value_t*)jl_bottom_type)) { + if (!jl_types_equal(astrt, rt)) { if (astrt == (jl_value_t*)jl_bottom_type) { jl_errorf("cfunction: %s does not return", li->name->name); } @@ -2551,7 +2549,7 @@ static void emit_assignment(jl_value_t *l, jl_value_t *r, jl_codectx_t *ctx) jl_varinfo_t &vi = ctx->vars[s]; jl_value_t *rt = expr_type(r,ctx); if ((jl_is_symbol(r) || jl_is_symbolnode(r)) && rt == jl_bottom_type) { - // sometimes x = y::None occurs + // sometimes x = y::Union() occurs if (builder.GetInsertBlock()->getTerminator() != NULL) return; } @@ -3462,7 +3460,7 @@ static Function *emit_function(jl_lambda_info_t *lam, bool cstyle) fsig.push_back(ty); } } - Type *rt = (jlrettype == (jl_value_t*)jl_nothing->type ? T_void : julia_type_to_llvm(jlrettype)); + Type *rt = (jlrettype == (jl_value_t*)jl_void_type ? T_void : julia_type_to_llvm(jlrettype)); f = Function::Create(FunctionType::get(rt, fsig, false), Function::ExternalLinkage, funcName.str(), m); if (lam->cFunctionObject == NULL) { @@ -4044,7 +4042,7 @@ extern "C" void jl_fptr_to_llvm(void *fptr, jl_lambda_info_t *lam, int specsig) if (ty != T_void && !ty->isEmptyTy()) fsig.push_back(ty); } - Type *rt = (jlrettype == (jl_value_t*)jl_nothing->type ? T_void : julia_type_to_llvm(jlrettype)); + Type *rt = (jlrettype == (jl_value_t*)jl_void_type ? T_void : julia_type_to_llvm(jlrettype)); Function *f = Function::Create(FunctionType::get(rt, fsig, false), #ifdef USE_MCJIT Function::ExternalLinkage, funcName, shadow_module); diff --git a/src/dump.c b/src/dump.c index ecd33116b607e..d79b35f15f93c 100644 --- a/src/dump.c +++ b/src/dump.c @@ -1201,8 +1201,8 @@ void jl_init_serializer(void) (void*)Int32_tag, (void*)Array1d_tag, (void*)Singleton_tag, jl_module_type, jl_tvar_type, jl_lambda_info_type, - jl_null, jl_false, jl_true, jl_any_type, jl_symbol("Any"), - jl_symbol("Array"), jl_symbol("TypeVar"), + jl_null, jl_false, jl_true, jl_nothing, jl_any_type, + jl_symbol("Any"), jl_symbol("Array"), jl_symbol("TypeVar"), jl_symbol("Box"), jl_symbol("apply"), lambda_sym, body_sym, return_sym, call_sym, colons_sym, null_sym, goto_ifnot_sym, assign_sym, @@ -1255,7 +1255,6 @@ void jl_init_serializer(void) jl_box_int32(51), jl_box_int32(52), jl_box_int32(53), jl_box_int32(54), jl_box_int32(55), jl_box_int32(56), jl_box_int32(57), jl_box_int32(58), jl_box_int32(59), - jl_box_int32(60), jl_box_int32(61), #endif jl_box_int64(0), jl_box_int64(1), jl_box_int64(2), jl_box_int64(3), jl_box_int64(4), jl_box_int64(5), @@ -1278,13 +1277,12 @@ void jl_init_serializer(void) jl_box_int64(51), jl_box_int64(52), jl_box_int64(53), jl_box_int64(54), jl_box_int64(55), jl_box_int64(56), jl_box_int64(57), jl_box_int64(58), jl_box_int64(59), - jl_box_int64(60), jl_box_int64(61), #endif jl_labelnode_type, jl_linenumbernode_type, jl_gotonode_type, jl_quotenode_type, jl_topnode_type, jl_type_type, jl_bottom_type, jl_pointer_type, jl_vararg_type, jl_ntuple_type, jl_abstractarray_type, - jl_densearray_type, jl_box_type, + jl_densearray_type, jl_box_type, jl_void_type, jl_typector_type, jl_undef_type, jl_top_type, jl_typename_type, jl_task_type, jl_uniontype_type, jl_typetype_type, jl_typetype_tvar, jl_ANY_flag, jl_array_any_type, jl_intrinsic_type, jl_method_type, @@ -1296,7 +1294,7 @@ void jl_init_serializer(void) jl_typename_type->name, jl_type_type->name, jl_methtable_type->name, jl_method_type->name, jl_tvar_type->name, jl_vararg_type->name, jl_ntuple_type->name, jl_abstractarray_type->name, - jl_densearray_type->name, + jl_densearray_type->name, jl_void_type->name, jl_lambda_info_type->name, jl_module_type->name, jl_box_type->name, jl_function_type->name, jl_typector_type->name, jl_intrinsic_type->name, jl_undef_type->name, jl_task_type->name, diff --git a/src/gf.c b/src/gf.c index a2ae90d84a055..e3d24764040a7 100644 --- a/src/gf.c +++ b/src/gf.c @@ -905,10 +905,10 @@ static jl_value_t *lookup_match(jl_value_t *a, jl_value_t *b, jl_tuple_t **penv, ee[n++] = val; /* since "a" is a concrete type, we assume that - (a∩b != None) => a<:b. However if a static parameter is - forced to equal None, then part of "b" might become None, + (a∩b != Union()) => a<:b. However if a static parameter is + forced to equal Union(), then part of "b" might become Union(), and therefore a subtype of "a". For example - (Type{None},Int) ∩ (Type{T},T) + (Type{Union()},Int) ∩ (Type{T},T) issue #5254 */ if (val == (jl_value_t*)jl_bottom_type) { diff --git a/src/init.c b/src/init.c index e91cff2ad2de0..2b943f70e59a3 100644 --- a/src/init.c +++ b/src/init.c @@ -1068,7 +1068,6 @@ static jl_value_t *basemod(char *name) // fetch references to things defined in boot.jl void jl_get_builtin_hooks(void) { - jl_nothing = core("nothing"); jl_root_task->tls = jl_nothing; jl_root_task->consumers = jl_nothing; jl_root_task->donenotify = jl_nothing; diff --git a/src/jltypes.c b/src/jltypes.c index 3f8b72f245263..745d18e865098 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -395,7 +395,7 @@ static jl_value_t *intersect_union(jl_uniontype_t *a, jl_value_t *b, return tu; } -// if returns with *bot!=0, then intersection is None +// if returns with *bot!=0, then intersection is Union() static size_t tuple_intersect_size(jl_tuple_t *a, jl_tuple_t *b, int *bot) { size_t al = jl_tuple_len(a); @@ -524,7 +524,7 @@ static jl_value_t *intersect_tag(jl_datatype_t *a, jl_datatype_t *b, ti = jl_type_intersect(ap,bp,penv,eqc,invariant); if (bp == (jl_value_t*)jl_bottom_type && !((jl_tvar_t*)ap)->bound) { - // "None" as a type parameter + // "Union()" as a type parameter jl_tupleset(p, i, ti); continue; } @@ -533,7 +533,7 @@ static jl_value_t *intersect_tag(jl_datatype_t *a, jl_datatype_t *b, ti = jl_type_intersect(ap,bp,penv,eqc,invariant); if (ap == (jl_value_t*)jl_bottom_type && !((jl_tvar_t*)bp)->bound) { - // "None" as a type parameter + // "Union()" as a type parameter jl_tupleset(p, i, ti); continue; } @@ -553,7 +553,7 @@ static jl_value_t *intersect_tag(jl_datatype_t *a, jl_datatype_t *b, else if (type_eqv_(ap,bp)) { ti = ap; if (ti == (jl_value_t*)jl_bottom_type) { - // "None" as a type parameter + // "Union()" as a type parameter jl_tupleset(p, i, ti); continue; } @@ -1017,7 +1017,7 @@ static jl_value_t *jl_type_intersect(jl_value_t *a, jl_value_t *b, // uses to instantiate its supertype. this tells us what subtype parameter // values are implied by the intersected supertype, or that the // intersected supertype cannot come from this subtype (in which case - // our final answer is None). + // our final answer is Union()). size_t i; // hack: we need type_match to find assignments for all typevars int prev_mim = match_intersection_mode; @@ -1064,7 +1064,7 @@ static jl_value_t *jl_type_intersect(jl_value_t *a, jl_value_t *b, if (jl_tupleref(env, e) == tp) { elt = jl_type_intersect(elt, jl_tupleref(env, e+1), penv, eqc, invariant); - // note: elt might be None if "None" was the type parameter + // note: elt might be Union() if "Union()" was the type parameter break; } } @@ -2086,7 +2086,7 @@ static int jl_subtype_le(jl_value_t *a, jl_value_t *b, int ta, int invariant) } } else if (a == b) { - // None <: None + // Union() <: Union() return 1; } size_t i; @@ -2857,7 +2857,6 @@ void jl_init_types(void) jl_null = (jl_tuple_t*)newobj((jl_value_t*)jl_tuple_type, 1); jl_tuple_set_len_unsafe(jl_null, 0); - jl_nothing = (jl_value_t*)jl_null; // for bootstrapping jl_any_type = jl_new_abstracttype((jl_value_t*)jl_symbol("Any"), NULL, jl_null); jl_any_type->super = jl_any_type; @@ -2937,6 +2936,11 @@ void jl_init_types(void) jl_sym_type->mutabl = 1; // now they can be used to create the remaining base kinds and types + jl_void_type = jl_new_datatype(jl_symbol("Void"), jl_any_type, jl_null, + jl_null, jl_null, 0, 0); + jl_nothing = newstruct(jl_void_type); + jl_void_type->instance = jl_nothing; + jl_uniontype_type = jl_new_datatype(jl_symbol("UnionType"), jl_type_type, jl_null, jl_tuple(1, jl_symbol("types")), @@ -3187,7 +3191,7 @@ void jl_init_types(void) // complete builtin type metadata jl_value_t *pointer_void = jl_apply_type((jl_value_t*)jl_pointer_type, - jl_tuple(1,jl_bottom_type)); + jl_tuple(1,jl_void_type)); jl_voidpointer_type = (jl_datatype_t*)pointer_void; jl_tupleset(jl_datatype_type->types, 0, pointer_void); jl_tupleset(jl_datatype_type->types, 9, jl_int32_type); diff --git a/src/julia.h b/src/julia.h index 32c603c5f9623..826b0c9798451 100644 --- a/src/julia.h +++ b/src/julia.h @@ -359,6 +359,7 @@ extern DLLEXPORT jl_datatype_t *jl_float32_type; extern DLLEXPORT jl_datatype_t *jl_float64_type; extern DLLEXPORT jl_datatype_t *jl_floatingpoint_type; extern DLLEXPORT jl_datatype_t *jl_number_type; +extern DLLEXPORT jl_datatype_t *jl_void_type; extern DLLEXPORT jl_datatype_t *jl_voidpointer_type; extern DLLEXPORT jl_datatype_t *jl_pointer_type; @@ -640,11 +641,11 @@ jl_datatype_t *jl_new_abstracttype(jl_value_t *name, jl_datatype_t *super, jl_tuple_t *parameters); DLLEXPORT jl_datatype_t *jl_new_uninitialized_datatype(size_t nfields); DLLEXPORT jl_datatype_t *jl_new_datatype(jl_sym_t *name, jl_datatype_t *super, - jl_tuple_t *parameters, - jl_tuple_t *fnames, jl_tuple_t *ftypes, - int abstract, int mutabl); + jl_tuple_t *parameters, + jl_tuple_t *fnames, jl_tuple_t *ftypes, + int abstract, int mutabl); DLLEXPORT jl_datatype_t *jl_new_bitstype(jl_value_t *name, jl_datatype_t *super, - jl_tuple_t *parameters, size_t nbits); + jl_tuple_t *parameters, size_t nbits); jl_datatype_t *jl_wrap_Type(jl_value_t *t); // x -> Type{x} jl_datatype_t *jl_wrap_vararg(jl_value_t *t); // x -> x... diff --git a/test/arrayops.jl b/test/arrayops.jl index abf073de17f05..2c16074ad6c0b 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -881,7 +881,7 @@ let end # issue #6977 -@test []' == Array(None,1,0) +@test size([]') == (1,0) # issue #6996 @test { 1 2; 3 4 }' == { 1 2; 3 4 }.' diff --git a/test/core.jl b/test/core.jl index cc5c712be1f31..9f75bc75e9c1d 100644 --- a/test/core.jl +++ b/test/core.jl @@ -1,5 +1,7 @@ # test core language features +const Bottom = Union() + # basic type relationships @test Int8 <: Integer @test Int32 <: Integer @@ -17,18 +19,18 @@ @test !(Array{Int8,1} <: Array{Any,1}) @test !(Array{Any,1} <: Array{Int8,1}) @test Array{Int8,1} <: Array{Int8,1} -@test !(Type{None} <: Type{Int32}) +@test !(Type{Bottom} <: Type{Int32}) @test !(Vector{Float64} <: Vector{Union(Float64,Float32)}) -@test is(None, typeintersect(Vector{Float64},Vector{Union(Float64,Float32)})) +@test is(Bottom, typeintersect(Vector{Float64},Vector{Union(Float64,Float32)})) @test !isa(Array,Type{Any}) @test Type{Complex} <: DataType @test isa(Complex,Type{Complex}) -@test !(Type{Ptr{None}} <: Type{Ptr}) +@test !(Type{Ptr{Bottom}} <: Type{Ptr}) @test !(Type{Rational{Int}} <: Type{Rational}) let T = TypeVar(:T,true) - @test !is(None, typeintersect(Array{None},AbstractArray{T})) - @test is(None, typeintersect((Type{Ptr{Uint8}},Ptr{None}), + @test !is(Bottom, typeintersect(Array{Bottom},AbstractArray{T})) + @test is(Bottom, typeintersect((Type{Ptr{Uint8}},Ptr{Bottom}), (Type{Ptr{T}},Ptr{T}))) @test !(Type{T} <: TypeVar) @@ -39,11 +41,11 @@ let T = TypeVar(:T,true) (Int, Array{Int,1})) @test isequal(typeintersect((T, AbstractArray{T}),(Int, Array{Number,1})), - None) + Bottom) @test isequal(typeintersect((T, AbstractArray{T}),(Any, Array{Number,1})), (Number, Array{Number,1})) - @test !is(None, typeintersect((Array{T}, Array{T}), (Array, Array{Any}))) + @test !is(Bottom, typeintersect((Array{T}, Array{T}), (Array, Array{Any}))) f47{T}(x::Vector{Vector{T}}) = 0 @test_throws MethodError f47(Array(Vector,0)) @test f47(Array(Vector{Int},0)) == 0 @@ -55,17 +57,17 @@ let T = TypeVar(:T,true) @test typeintersect(Type{TypeVar(:T,Array{TT,1})},Type{Array{S,N}}) == Type{Array{S,1}} # issue #5359 @test typeintersect((Type{Array{T,1}},Array{T,1}), - (Type{AbstractVector},Vector{Int})) === None + (Type{AbstractVector},Vector{Int})) === Bottom # issue #5559 @test typeintersect((Type{Vector{Complex128}}, AbstractVector), (Type{Array{T,N}}, Array{S,N})) == (Type{Vector{Complex128}},Vector) @test typeintersect((Type{Vector{Complex128}}, AbstractArray), (Type{Array{T,N}}, Array{S,N})) == (Type{Vector{Complex128}},Vector) - @test typeintersect(Type{Array{T}}, Type{AbstractArray{T}}) === None + @test typeintersect(Type{Array{T}}, Type{AbstractArray{T}}) === Bottom - @test typeintersect(Type{(Bool,Int...)}, Type{(T...)}) === None - @test typeintersect(Type{(Bool,Int...)}, Type{(T,T...)}) === None + @test typeintersect(Type{(Bool,Int...)}, Type{(T...)}) === Bottom + @test typeintersect(Type{(Bool,Int...)}, Type{(T,T...)}) === Bottom end let N = TypeVar(:N,true) @test isequal(typeintersect((NTuple{N,Integer},NTuple{N,Integer}), @@ -82,24 +84,24 @@ let N = TypeVar(:N,true) ((Int,Int...),Array{Int,2})), ((Int,Int), Array{Int,2})) - @test isequal(typeintersect((Type{Nothing},Type{Nothing}), Type{NTuple{N,Nothing}}), - Type{(Nothing,Nothing)}) + @test isequal(typeintersect((Type{Void},Type{Void}), Type{NTuple{N,Void}}), + Type{(Void,Void)}) end -@test is(None, typeintersect(Type{Any},Type{Complex})) -@test is(None, typeintersect(Type{Any},Type{TypeVar(:T,Real)})) +@test is(Bottom, typeintersect(Type{Any},Type{Complex})) +@test is(Bottom, typeintersect(Type{Any},Type{TypeVar(:T,Real)})) @test !(Type{Array{Integer}} <: Type{AbstractArray{Integer}}) @test !(Type{Array{Integer}} <: Type{Array{TypeVar(:T,Integer)}}) -@test is(None, typeintersect(Type{Function},UnionType)) +@test is(Bottom, typeintersect(Type{Function},UnionType)) @test is(Type{Int32}, typeintersect(Type{Int32},DataType)) @test !(Type <: TypeVar) -@test !is(None, typeintersect(DataType, Type)) -@test !is(None, typeintersect(UnionType, Type)) -@test !is(None, typeintersect(DataType, Type{Int})) -@test !is(None, typeintersect(DataType, Type{TypeVar(:T,Int)})) -@test !is(None, typeintersect(DataType, Type{TypeVar(:T,Integer)})) +@test !is(Bottom, typeintersect(DataType, Type)) +@test !is(Bottom, typeintersect(UnionType, Type)) +@test !is(Bottom, typeintersect(DataType, Type{Int})) +@test !is(Bottom, typeintersect(DataType, Type{TypeVar(:T,Int)})) +@test !is(Bottom, typeintersect(DataType, Type{TypeVar(:T,Integer)})) @test typeintersect((Int...), (Bool...)) === () -@test typeintersect(Type{(Int...)}, Type{(Bool...)}) === None +@test typeintersect(Type{(Int...)}, Type{(Bool...)}) === Bottom @test typeintersect((Bool,Int...), (Bool...)) === (Bool,) let T = TypeVar(:T,Union(Float32,Float64)) @@ -129,8 +131,8 @@ end @test issubtype(Array{(Any...)}, Array{NTuple}) @test !issubtype(Array{(Int...)}, Array{NTuple}) @test !issubtype(Array{(Int,Int)}, Array{NTuple}) -@test issubtype(Type{(Nothing,)}, (Type{Nothing},)) -@test issubtype((Type{Nothing},),Type{(Nothing,)}) +@test issubtype(Type{(Void,)}, (Type{Void},)) +@test issubtype((Type{Void},),Type{(Void,)}) # this is fancy: know that any type T<:Number must be either a DataType or a UnionType @test Type{TypeVar(:T,Number)} <: Union(DataType,UnionType) @@ -138,8 +140,8 @@ end @test Type{TypeVar(:T,Tuple)} <: Union(Tuple,UnionType) @test !(Type{TypeVar(:T,Tuple)} <: Union(DataType,UnionType)) -@test !is(None, typeintersect((DataType,DataType),Type{TypeVar(:T,(Number,Number))})) -@test !is(None, typeintersect((DataType,UnionType),Type{(Number,None)})) +@test !is(Bottom, typeintersect((DataType,DataType),Type{TypeVar(:T,(Number,Number))})) +@test !is(Bottom, typeintersect((DataType,UnionType),Type{(Number,Bottom)})) # issue #2997 let T = TypeVar(:T,Union(Float64,Array{Float64,1}),true) @@ -164,7 +166,7 @@ end @test Base.typeseq(typejoin(Union(Int,String),Int), Union(Int,String)) @test Base.typeseq(typejoin(Union(Int,String),Int8), Any) -@test promote_type(Bool,None) === Bool +@test promote_type(Bool,Bottom) === Bool # ntuples nttest1{n}(x::NTuple{n,Int}) = n @@ -613,12 +615,11 @@ end # sufficient information # issue #814 begin - local MatOrNothing, my_func, M - typealias MatOrNothing{T} Union(AbstractMatrix{T}, Vector{None}) - my_func{T<:Real}(A::MatOrNothing{T}, B::MatOrNothing{T}, - C::MatOrNothing{T}) = 0 + local MatOrNot, my_func, M + typealias MatOrNot{T} Union(AbstractMatrix{T}, Vector{Union()}) + my_func{T<:Real}(A::MatOrNot{T}, B::MatOrNot{T}, C::MatOrNot{T}) = 0 M = [ 2. 1. ; 1. 1. ] - @test my_func([], M, M) == 0 + @test my_func(Union()[], M, M) == 0 end begin @@ -866,7 +867,7 @@ end # issue #2365 type B2365{T} - v::Union(T, Nothing) + v::Union(T, Void) end @test B2365{Int}(nothing).v === nothing @test B2365{Int}(0).v === 0 @@ -1036,7 +1037,7 @@ function foo(x) end return ret end -x = Array(Union(Dict{Int64,String},Array{Int64,3},Number,String,Nothing), 3) +x = Array(Union(Dict{Int64,String},Array{Int64,3},Number,String,Void), 3) x[1] = 1.0 x[2] = 2.0 x[3] = 3.0 @@ -1153,7 +1154,7 @@ try end # issue #4526 -f4526(x) = isa(x.a, Nothing) +f4526(x) = isa(x.a, Void) @test_throws ErrorException f4526(1) @test_throws ErrorException f4526(im) @test_throws ErrorException f4526(1+2im) @@ -1261,7 +1262,7 @@ abstract IT4805{N, T} let T = TypeVar(:T,Int,true) N = TypeVar(:N,true) - @test typeintersect(Type{IT4805{1,T}}, Type{TypeVar(:_,IT4805{N,Int})}) != None + @test typeintersect(Type{IT4805{1,T}}, Type{TypeVar(:_,IT4805{N,Int})}) != Bottom end let @@ -1301,7 +1302,7 @@ f5150(T) = Array(Rational{T},1) # issue #5165 bitstype 64 T5165{S} -make_t(x::Int64) = Base.box(T5165{Nothing}, Base.unbox(Int64, x)) +make_t(x::Int64) = Base.box(T5165{Void}, Base.unbox(Int64, x)) xs5165 = T5165[make_t(int64(1))] b5165 = IOBuffer() for x in xs5165 @@ -1334,7 +1335,7 @@ end # issue #5254 f5254{T}(::Type{T}, b::T) = 0 f5254(a, b) = 1 -@test f5254(None, 1) == 1 +@test f5254(Bottom, 1) == 1 # evaluate arguments left-to-right, including assignments. issue #4990 let @@ -1360,7 +1361,7 @@ cnvt(T, x) = convert_default(T, x, cnvt) cnvt{S, T, N}(::Type{Array{S, N}}, x::Array{T, N}) = convert(Array{S}, x) function tighttypes!(adf) - T = None + T = Bottom tt = {Int} for t in tt T = typejoin(T, t) @@ -1737,7 +1738,7 @@ f6980(::Union(Int, Float64), ::B6980) = true @test f6980(1, B6980()) # issue #7049 -typealias Maybe7049{T} Union(T,Nothing) +typealias Maybe7049{T} Union(T,Void) function ttt7049(;init::Maybe7049{Union(String,(Int,Char))} = nothing) string("init=", init) end @@ -1842,8 +1843,8 @@ end # issue #8184 immutable Foo8184 - x::Nothing - y::Nothing + x::Void + y::Void z::Float64 end let f = Foo8184(nothing,nothing,1.0) diff --git a/test/functional.jl b/test/functional.jl index 0c222b45666d5..4afe89609bce9 100644 --- a/test/functional.jl +++ b/test/functional.jl @@ -13,9 +13,9 @@ let io=IOBuffer(3) @test takebuf_string(io)=="12" end -# map over [] should return [] +# map over Bottom[] should return Bottom[] # issue #6719 -@test isequal(typeof(map(x -> x, [])), Array{None,1}) +@test isequal(typeof(map(x -> x, Array(Union(),0))), Array{Union(),1}) # maps of tuples (formerly in test/core.jl) -- tuple.jl @test map((x,y)->x+y,(1,2,3),(4,5,6)) == (5,7,9)