diff --git a/base/abstractarray.jl b/base/abstractarray.jl index d40f0ae4ac140..1343dc969949b 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -619,8 +619,8 @@ typed_hcat(T::Type) = Array{T}(0) ## cat: special cases 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) ] -hcat{T}(X::T...) = T[ X[j] for i=1, j=1:length(X) ] -hcat{T<:Number}(X::T...) = T[ X[j] for i=1, j=1:length(X) ] +hcat{T}(X::T...) = T[ X[j] for i=1:1, j=1:length(X) ] +hcat{T<:Number}(X::T...) = T[ X[j] for i=1:1, j=1:length(X) ] vcat(X::Number...) = hvcat_fill(Array{promote_typeof(X...)}(length(X)), X) hcat(X::Number...) = hvcat_fill(Array{promote_typeof(X...)}(1,length(X)), X) diff --git a/base/arraymath.jl b/base/arraymath.jl index 235bffe676296..c96eb53745c19 100644 --- a/base/arraymath.jl +++ b/base/arraymath.jl @@ -352,8 +352,8 @@ function ctranspose(A::AbstractMatrix) end ctranspose{T<:Real}(A::AbstractVecOrMat{T}) = transpose(A) -transpose(x::AbstractVector) = [ transpose(v) for i=1, v in x ] -ctranspose{T}(x::AbstractVector{T}) = T[ ctranspose(v) for i=1, v in x ] #Fixme comprehension +transpose(x::AbstractVector) = [ transpose(v) for i=1:1, v in x ] +ctranspose{T}(x::AbstractVector{T}) = T[ ctranspose(v) for i=1:1, v in x ] #Fixme comprehension _cumsum_type{T<:Number}(v::AbstractArray{T}) = typeof(+zero(T)) _cumsum_type(v) = typeof(v[1]+v[1]) diff --git a/base/generator.jl b/base/generator.jl index 48e00c749b84e..c7d487f14eef1 100644 --- a/base/generator.jl +++ b/base/generator.jl @@ -17,9 +17,10 @@ Generator(f, c1, c...) = Generator(a->f(a...), zip(c1, c...)) Generator{T,I}(::Type{T}, iter::I) = Generator{I,Type{T}}(T, iter) -start(g::Generator) = start(g.iter) -done(g::Generator, s) = done(g.iter, s) +start(g::Generator) = (@_inline_meta; start(g.iter)) +done(g::Generator, s) = (@_inline_meta; done(g.iter, s)) function next(g::Generator, s) + @_inline_meta v, s2 = next(g.iter, s) g.f(v), s2 end diff --git a/base/inference.jl b/base/inference.jl index 8fc5c51d7c043..1fcc3555cc8e5 100644 --- a/base/inference.jl +++ b/base/inference.jl @@ -42,10 +42,8 @@ type InferenceState atypes #::Type # type sig sp::SimpleVector # static parameters label_counter::Int # index of the current highest label for this function - fedbackvars::Dict{SSAValue, Bool} mod::Module currpc::LineNum - static_typeof::Bool # info on the state of inference and the linfo linfo::LambdaInfo @@ -71,7 +69,6 @@ type InferenceState backedges::Vector{Tuple{InferenceState, Vector{LineNum}}} # iteration fixed-point detection fixedpoint::Bool - typegotoredo::Bool inworkq::Bool optimize::Bool inferred::Bool @@ -157,13 +154,13 @@ type InferenceState inmodule = isdefined(linfo, :def) ? linfo.def.module : current_module() # toplevel thunks are inferred in the current module frame = new( - atypes, sp, nl, Dict{SSAValue, Bool}(), inmodule, 0, false, + atypes, sp, nl, inmodule, 0, linfo, linfo, la, s, Union{}, W, n, cur_hand, handler_at, n_handlers, ssavalue_uses, ssavalue_init, ObjectIdDict(), #Dict{InferenceState, Vector{LineNum}}(), Vector{Tuple{InferenceState, Vector{LineNum}}}(), - false, false, false, optimize, false, nothing) + false, false, optimize, false, nothing) push!(active, frame) nactive[] += 1 return frame @@ -1070,8 +1067,6 @@ function abstract_eval(e::ANY, vtypes::VarTable, sv::InferenceState) return abstract_eval_constant(e) end e = e::Expr - # handle: - # call null new & static_typeof if is(e.head,:call) t = abstract_eval_call(e, vtypes, sv) elseif is(e.head,:null) @@ -1105,42 +1100,6 @@ function abstract_eval(e::ANY, vtypes::VarTable, sv::InferenceState) t = abstract_eval_constant(val) end end - elseif is(e.head,:static_typeof) - var = e.args[1] - t = widenconst(abstract_eval(var, vtypes, sv)) - if isa(t,DataType) && typeseq(t,t.name.primary) - # remove unnecessary typevars - t = t.name.primary - end - if is(t,Bottom) - # if we haven't gotten fed-back type info yet, return Bottom. otherwise - # Bottom is the actual type of the variable, so return Type{Bottom}. - if get!(sv.fedbackvars, var, false) - t = Type{Bottom} - else - sv.static_typeof = true - end - elseif isleaftype(t) - t = Type{t} - elseif isleaftype(sv.atypes) - if isa(t,TypeVar) - t = Type{t.ub} - else - t = Type{t} - end - else - # if there is any type uncertainty in the arguments, we are - # effectively predicting what static_typeof will say when - # the function is compiled with actual arguments. in that case - # abstract types yield Type{<:T} instead of Type{T}. - # this doesn't really model the situation perfectly, but - # "isleaftype(inference_stack.types)" should be good enough. - if isa(t,TypeVar) || isvarargtype(t) - t = Type{t} - else - t = Type{TypeVar(:_,t)} - end - end elseif is(e.head,:method) t = (length(e.args) == 1) ? Any : Void elseif is(e.head,:copyast) @@ -1631,7 +1590,6 @@ function typeinf_frame(frame) W = frame.ip s = frame.stmt_types n = frame.nstmts - @label restart_typeinf while !isempty(W) # make progress on the active ip set local pc::Int = first(W), pc´::Int @@ -1639,15 +1597,12 @@ function typeinf_frame(frame) #print(pc,": ",s[pc],"\n") delete!(W, pc) frame.currpc = pc - frame.static_typeof = false frame.cur_hand = frame.handler_at[pc] stmt = frame.linfo.code[pc] changes = abstract_interpret(stmt, s[pc]::Array{Any,1}, frame) if changes === () - # if there was a Expr(:static_typeof) on this line, - # need to continue to the next pc even though the return type was Bottom - # otherwise, this line threw an error and there is no need to continue - frame.static_typeof || break + # this line threw an error and there is no need to continue + break changes = s[pc] end if frame.cur_hand !== () @@ -1697,26 +1652,6 @@ function typeinf_frame(frame) s[l] = newstate end end - elseif is(hd, :type_goto) - for i = 2:length(stmt.args) - var = stmt.args[i]::SSAValue - # Store types that need to be fed back via type_goto - # in ssavalue_init. After finishing inference, if any - # of these types changed, start over with the fed-back - # types known from the beginning. - # See issue #3821 (using !typeseq instead of !subtype), - # and issue #7810. - id = var.id+1 - vt = frame.linfo.ssavaluetypes[id] - ot = frame.ssavalue_init[id] - if ot===NF || !(vt⊑ot && ot⊑vt) - frame.ssavalue_init[id] = vt - if get(frame.fedbackvars, var, false) - frame.typegotoredo = true - end - end - frame.fedbackvars[var] = true - end elseif is(hd, :return) pc´ = n + 1 rt = abstract_eval(stmt.args[1], s[pc], frame) @@ -1786,39 +1721,6 @@ function typeinf_frame(frame) end if finished || frame.fixedpoint - if frame.typegotoredo - # if any type_gotos changed, clear state and restart. - frame.typegotoredo = false - for ll = 2:length(s) - s[ll] = () - end - empty!(W) - push!(W, 1) - frame.cur_hand = () - frame.handler_at = Any[ () for i=1:n ] - frame.n_handlers = 0 - frame.linfo.ssavaluetypes[:] = frame.ssavalue_init - @goto restart_typeinf - else - # if a static_typeof was never reached, - # use Union{} as its real type and continue - # running type inference from its uses - # (one of which is the static_typeof) - # TODO: this restart should happen just before calling finish() - for (fbvar, seen) in frame.fedbackvars - if !seen - frame.fedbackvars[fbvar] = true - id = (fbvar::SSAValue).id + 1 - for r in frame.ssavalue_uses[id] - if !is(s[r], ()) # s[r] === () => unreached statement - push!(W, r) - end - end - @goto restart_typeinf - end - end - end - if finished finish(frame) else # fixedpoint propagation @@ -2000,7 +1902,7 @@ function eval_annotate(e::ANY, vtypes::ANY, sv::InferenceState, undefs, pass) e = e::Expr head = e.head - if is(head,:static_typeof) || is(head,:line) || is(head,:const) + if is(head,:line) || is(head,:const) return e elseif is(head,:(=)) e.args[2] = eval_annotate(e.args[2], vtypes, sv, undefs, pass) @@ -2222,9 +2124,6 @@ function effect_free(e::ANY, sv, allow_volatile::Bool) end if isa(e,Expr) e = e::Expr - if e.head === :static_typeof - return true - end if e.head === :static_parameter return true end diff --git a/base/iterator.jl b/base/iterator.jl index c3479f8fab74b..34ee076d6ad86 100644 --- a/base/iterator.jl +++ b/base/iterator.jl @@ -440,7 +440,6 @@ immutable IteratorND{I,N} end new{I,N}(iter, shape) end - (::Type{IteratorND}){I<:AbstractProdIterator}(p::I) = IteratorND(p, size(p)) end start(i::IteratorND) = start(i.iter) diff --git a/base/range.jl b/base/range.jl index 0135ebb720c8f..ada30ae329880 100644 --- a/base/range.jl +++ b/base/range.jl @@ -384,7 +384,7 @@ maximum(r::UnitRange) = isempty(r) ? throw(ArgumentError("range must be non-empt minimum(r::Range) = isempty(r) ? throw(ArgumentError("range must be non-empty")) : min(first(r), last(r)) maximum(r::Range) = isempty(r) ? throw(ArgumentError("range must be non-empty")) : max(first(r), last(r)) -ctranspose(r::Range) = [x for _=1, x=r] +ctranspose(r::Range) = [x for _=1:1, x=r] transpose(r::Range) = r' # Ranges are immutable diff --git a/base/sparse/sparsematrix.jl b/base/sparse/sparsematrix.jl index 803f60b75836b..4ab6e29a0564a 100644 --- a/base/sparse/sparsematrix.jl +++ b/base/sparse/sparsematrix.jl @@ -2802,8 +2802,8 @@ end function vcat(X::SparseMatrixCSC...) num = length(X) - mX = [ size(x, 1) for x in X ] - nX = [ size(x, 2) for x in X ] + mX = Int[ size(x, 1) for x in X ] + nX = Int[ size(x, 2) for x in X ] m = sum(mX) n = nX[1] @@ -2820,7 +2820,7 @@ function vcat(X::SparseMatrixCSC...) Ti = promote_type(Ti, eltype(X[i].rowval)) end - nnzX = [ nnz(x) for x in X ] + nnzX = Int[ nnz(x) for x in X ] nnz_res = sum(nnzX) colptr = Array{Ti}(n + 1) rowval = Array{Ti}(nnz_res) @@ -2862,8 +2862,8 @@ end function hcat(X::SparseMatrixCSC...) num = length(X) - mX = [ size(x, 1) for x in X ] - nX = [ size(x, 2) for x in X ] + mX = Int[ size(x, 1) for x in X ] + nX = Int[ size(x, 2) for x in X ] m = mX[1] for i = 2 : num if mX[i] != m; throw(DimensionMismatch("")); end @@ -2874,7 +2874,7 @@ function hcat(X::SparseMatrixCSC...) Ti = promote_type(map(x->eltype(x.rowval), X)...) colptr = Array{Ti}(n + 1) - nnzX = [ nnz(x) for x in X ] + nnzX = Int[ nnz(x) for x in X ] nnz_res = sum(nnzX) rowval = Array{Ti}(nnz_res) nzval = Array{Tv}(nnz_res) @@ -2930,8 +2930,8 @@ Concatenate matrices block-diagonally. Currently only implemented for sparse mat """ function blkdiag(X::SparseMatrixCSC...) num = length(X) - mX = [ size(x, 1) for x in X ] - nX = [ size(x, 2) for x in X ] + mX = Int[ size(x, 1) for x in X ] + nX = Int[ size(x, 2) for x in X ] m = sum(mX) n = sum(nX) @@ -2939,7 +2939,7 @@ function blkdiag(X::SparseMatrixCSC...) Ti = promote_type(map(x->eltype(x.rowval), X)...) colptr = Array{Ti}(n + 1) - nnzX = [ nnz(x) for x in X ] + nnzX = Int[ nnz(x) for x in X ] nnz_res = sum(nnzX) rowval = Array{Ti}(nnz_res) nzval = Array{Tv}(nnz_res) @@ -3180,7 +3180,7 @@ function trace{Tv}(A::SparseMatrixCSC{Tv}) s end -diag(A::SparseMatrixCSC) = [d for d in SpDiagIterator(A)] +diag{Tv}(A::SparseMatrixCSC{Tv}) = Tv[d for d in SpDiagIterator(A)] function diagm{Tv,Ti}(v::SparseMatrixCSC{Tv,Ti}) if (size(v,1) != 1 && size(v,2) != 1) diff --git a/src/alloc.c b/src/alloc.c index 2a72e5dbb39f0..7b95f1f720120 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -87,13 +87,12 @@ jl_sym_t *null_sym; jl_sym_t *body_sym; jl_sym_t *method_sym; jl_sym_t *core_sym; jl_sym_t *enter_sym; jl_sym_t *leave_sym; jl_sym_t *exc_sym; jl_sym_t *error_sym; -jl_sym_t *static_typeof_sym; jl_sym_t *globalref_sym; jl_sym_t *new_sym; jl_sym_t *using_sym; jl_sym_t *const_sym; jl_sym_t *thunk_sym; jl_sym_t *anonymous_sym; jl_sym_t *underscore_sym; jl_sym_t *abstracttype_sym; jl_sym_t *bitstype_sym; -jl_sym_t *compositetype_sym; jl_sym_t *type_goto_sym; +jl_sym_t *compositetype_sym; jl_sym_t *global_sym; jl_sym_t *list_sym; jl_sym_t *dot_sym; jl_sym_t *newvar_sym; jl_sym_t *boundscheck_sym; jl_sym_t *inbounds_sym; diff --git a/src/codegen.cpp b/src/codegen.cpp index cf75900425224..54069a0d0a0d0 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -3096,7 +3096,7 @@ static void emit_stmtpos(jl_value_t *expr, jl_codectx_t *ctx) if (jl_is_expr(expr)) { jl_sym_t *head = ((jl_expr_t*)expr)->head; // some expression types are metadata and can be ignored in statement position - if (head == line_sym || head == type_goto_sym || head == meta_sym) + if (head == line_sym || head == meta_sym) return; // fall-through } @@ -3270,18 +3270,6 @@ static jl_cgval_t emit_expr(jl_value_t *expr, jl_codectx_t *ctx) else if (head == null_sym) { return ghostValue(jl_void_type); } - else if (head == static_typeof_sym) { - jl_value_t *extype = expr_type((jl_value_t*)ex, ctx); - if (jl_is_type_type(extype)) { - extype = jl_tparam0(extype); - if (jl_is_typevar(extype)) - extype = ((jl_tvar_t*)extype)->ub; - } - else { - extype = (jl_value_t*)jl_any_type; - } - return mark_julia_const(extype); - } else if (head == new_sym) { jl_value_t *ty = expr_type(args[0], ctx); size_t nargs = jl_array_len(ex->args); diff --git a/src/interpreter.c b/src/interpreter.c index 20bd8e00f2e44..bb1af77c6f330 100644 --- a/src/interpreter.c +++ b/src/interpreter.c @@ -230,9 +230,6 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, jl_lambda_info_t *la else if (ex->head == exc_sym) { return jl_exception_in_transit; } - else if (ex->head == static_typeof_sym) { - return (jl_value_t*)jl_any_type; - } else if (ex->head == method_sym) { jl_sym_t *fname = (jl_sym_t*)args[0]; assert(jl_expr_nargs(ex) != 1 || jl_is_symbol(fname)); diff --git a/src/jltypes.c b/src/jltypes.c index bc825288049e3..11bb15eddab76 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -3758,7 +3758,6 @@ void jl_init_types(void) exc_sym = jl_symbol("the_exception"); enter_sym = jl_symbol("enter"); leave_sym = jl_symbol("leave"); - static_typeof_sym = jl_symbol("static_typeof"); new_sym = jl_symbol("new"); const_sym = jl_symbol("const"); global_sym = jl_symbol("global"); @@ -3769,7 +3768,6 @@ void jl_init_types(void) abstracttype_sym = jl_symbol("abstract_type"); bitstype_sym = jl_symbol("bits_type"); compositetype_sym = jl_symbol("composite_type"); - type_goto_sym = jl_symbol("type_goto"); toplevel_sym = jl_symbol("toplevel"); dot_sym = jl_symbol("."); boundscheck_sym = jl_symbol("boundscheck"); diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index fcbcc6aa9e860..195dbd90e880a 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -2022,82 +2022,33 @@ `(call (top Generator) (-> ,argname (block ,@splat ,expr)) ,(if (length= ranges 1) (car ranges) - `(call (top IteratorND) (call (top product) ,@ranges)))))))) + `(call (top product) ,@ranges))))))) 'comprehension (lambda (e) - (expand-forms (lower-comprehension #f (cadr e) (cddr e)))) + (if (any (lambda (x) (eq? x ':)) (cddr e)) + (error "N-d comprehension syntax has been removed")) + (expand-forms `(call (top collect) (generator ,(cadr e) ,@(cddr e))))) 'typed_comprehension (lambda (e) + (if (any (lambda (x) (eq? x ':)) (cdddr e)) + (error "N-d comprehension syntax has been removed")) (expand-forms (lower-comprehension (cadr e) (caddr e) (cdddr e)))) 'dict_comprehension (lambda (e) (syntax-deprecation #f "[a=>b for (a,b) in c]" "Dict(a=>b for (a,b) in c)") - (expand-forms (lower-dict-comprehension (cadr e) (cddr e)))) + (expand-forms `(call (top Dict) (generator ,(cadr e) ,@(cddr e))))) 'typed_dict_comprehension - (lambda (e) - (expand-forms (lower-typed-dict-comprehension (cadr e) (caddr e) (cdddr e)))))) - -(define (lower-nd-comprehension atype expr ranges) - (let ((result (make-ssavalue)) - (ri (gensy)) - (oneresult (gensy))) - ;; evaluate one expression to figure out type and size - ;; compute just one value by inserting a break inside loops - (define (evaluate-one ranges) - (if (null? ranges) - `(= ,oneresult ,expr) - (if (eq? (car ranges) `:) - (evaluate-one (cdr ranges)) - `(for ,(car ranges) - (block ,(evaluate-one (cdr ranges)) - (break)) )))) - - ;; compute the dimensions of the result - (define (compute-dims ranges oneresult-dim) - (if (null? ranges) - (list) - (if (eq? (car ranges) `:) - (cons `(call (top size) ,oneresult ,oneresult-dim) - (compute-dims (cdr ranges) (+ oneresult-dim 1))) - (cons `(call (top length) ,(caddr (car ranges))) - (compute-dims (cdr ranges) oneresult-dim)) ))) - - ;; construct loops to cycle over all dimensions of an n-d comprehension - (define (construct-loops ranges iters oneresult-dim) - (if (null? ranges) - (if (null? iters) - `(block (call (top setindex!) ,result ,expr ,ri) - (= ,ri (call (top +) ,ri) 1)) - `(block (call (top setindex!) ,result (ref ,expr ,@(reverse iters)) ,ri) - (= ,ri (call (top +) ,ri 1))) ) - (if (eq? (car ranges) `:) - (let ((i (make-ssavalue))) - `(for (= ,i (: 1 (call (top size) ,oneresult ,oneresult-dim))) - ,(construct-loops (cdr ranges) (cons i iters) (+ oneresult-dim 1)) )) - `(for ,(car ranges) - ,(construct-loops (cdr ranges) iters oneresult-dim) )))) - - ;; Evaluate the comprehension - `(scope-block - (block - (local ,oneresult) - ,(evaluate-one ranges) - (= ,result (call (core Array) ,(if atype atype `(call (top eltype) ,oneresult)) - ,@(compute-dims ranges 1))) - (= ,ri 1) - ,(construct-loops (reverse ranges) (list) 1) - ,result )))) + (lambda (e) (expand-forms + `(call (call (core apply_type) (top Dict) ,@(cdr (cadr e))) + (generator ,(caddr e) ,@(cdddr e))))))) (define (lower-comprehension atype expr ranges) - (if (any (lambda (x) (eq? x ':)) ranges) - (lower-nd-comprehension atype expr ranges) (let ((result (make-ssavalue)) (ri (gensy)) - (initlabl (if atype #f (make-ssavalue))) (oneresult (make-ssavalue)) (lengths (map (lambda (x) (make-ssavalue)) ranges)) (states (map (lambda (x) (gensy)) ranges)) @@ -2108,7 +2059,6 @@ (define (construct-loops ranges rv is states lengths) (if (null? ranges) `(block (= ,oneresult ,expr) - ,@(if atype '() `((type_goto ,initlabl ,oneresult))) (inbounds true) (call (top setindex!) ,result ,oneresult ,ri) (inbounds pop) @@ -2134,79 +2084,10 @@ ,.(map (lambda (v r) `(= ,v (call (top length) ,r))) lengths rv) (scope-block (block - ,@(if atype '() `((label ,initlabl))) - (= ,result (call (core Array) - ,(if atype atype `(static_typeof ,oneresult)) - ,@lengths)) + (= ,result (call (core Array) ,atype ,@lengths)) (= ,ri 1) ,(construct-loops (reverse ranges) (reverse rv) is states (reverse lengths)) - ,result)))))) - -(define (lower-dict-comprehension expr ranges) - (let ((result (make-ssavalue)) - (initlabl (make-ssavalue)) - (onekey (make-ssavalue)) - (oneval (make-ssavalue)) - (rv (map (lambda (x) (make-ssavalue)) ranges))) - - ;; construct loops to cycle over all dimensions of an n-d comprehension - (define (construct-loops ranges) - (if (null? ranges) - `(block (= ,onekey ,(cadr expr)) - (= ,oneval ,(caddr expr)) - (type_goto ,initlabl ,onekey ,oneval) - (call (top setindex!) ,result ,oneval ,onekey)) - `(for ,(car ranges) - (block - ;; *** either this or force all for loop vars local - ,.(map (lambda (r) `(local ,r)) - (lhs-vars (cadr (car ranges)))) - ,(construct-loops (cdr ranges)))))) - - ;; Evaluate the comprehension - (let ((loopranges - (map (lambda (r v) `(= ,(cadr r) ,v)) ranges rv))) - `(block - ,.(map (lambda (v r) `(= ,v ,(caddr r))) rv ranges) - (scope-block - (block - #;,@(map (lambda (r) `(local ,r)) - (apply append (map (lambda (r) (lhs-vars (cadr r))) ranges))) - (label ,initlabl) - (= ,result (call (curly (top Dict) - (static_typeof ,onekey) - (static_typeof ,oneval)))) - ,(construct-loops (reverse loopranges)) - ,result)))))) - -(define (lower-typed-dict-comprehension atypes expr ranges) - (if (not (and (length= atypes 3) - (eq? (car atypes) '=>))) - (error "invalid \"typed_dict_comprehension\" syntax") - (let ( (result (make-ssavalue)) - (rs (map (lambda (x) (make-ssavalue)) ranges)) ) - - ;; construct loops to cycle over all dimensions of an n-d comprehension - (define (construct-loops ranges rs) - (if (null? ranges) - `(call (top setindex!) ,result ,(caddr expr) ,(cadr expr)) - `(for (= ,(cadr (car ranges)) ,(car rs)) - (block - ;; *** either this or force all for loop vars local - ,.(map (lambda (r) `(local ,r)) - (lhs-vars (cadr (car ranges)))) - ,(construct-loops (cdr ranges) (cdr rs)))))) - - ;; Evaluate the comprehension - `(block - ,.(map make-assignment rs (map caddr ranges)) - (= ,result (call (curly (top Dict) ,(cadr atypes) ,(caddr atypes)))) - (scope-block - (block - #;,@(map (lambda (r) `(local ,r)) - (apply append (map (lambda (r) (lhs-vars (cadr r))) ranges))) - ,(construct-loops (reverse ranges) (reverse rs)) - ,result)))))) + ,result))))) (define (lhs-vars e) (cond ((symbol? e) (list e)) @@ -3180,17 +3061,6 @@ f(x) = yt(x) (cons (list code handler-level (cadr e)) handler-goto-fixups)) '(null))) - ((type_goto) - (let ((m (get label-map (cadr e) #f))) - (if m - (emit `(type_goto ,m ,@(cddr e))) - (let ((l (make-label))) - (put! label-map (cadr e) l) - (emit `(type_goto ,l ,@(cddr e))))))) - ((static_typeof) - (assert (and value (not tail))) - e) - ;; exception handlers are lowered using ;; (enter L) - push handler with catch block at label L ;; (leave n) - pop N exception handlers diff --git a/src/julia.h b/src/julia.h index 3f751a191ad9e..77b87c47298e5 100644 --- a/src/julia.h +++ b/src/julia.h @@ -559,11 +559,11 @@ extern jl_sym_t *null_sym; extern jl_sym_t *body_sym; extern jl_sym_t *method_sym; extern jl_sym_t *slot_sym; extern jl_sym_t *enter_sym; extern jl_sym_t *leave_sym; extern jl_sym_t *exc_sym; extern jl_sym_t *new_sym; -extern jl_sym_t *static_typeof_sym; extern jl_sym_t *compiler_temp_sym; +extern jl_sym_t *compiler_temp_sym; extern jl_sym_t *const_sym; extern jl_sym_t *thunk_sym; extern jl_sym_t *anonymous_sym; extern jl_sym_t *underscore_sym; extern jl_sym_t *abstracttype_sym; extern jl_sym_t *bitstype_sym; -extern jl_sym_t *compositetype_sym; extern jl_sym_t *type_goto_sym; +extern jl_sym_t *compositetype_sym; extern jl_sym_t *global_sym; extern jl_sym_t *unused_sym; extern jl_sym_t *boundscheck_sym; extern jl_sym_t *inbounds_sym; extern jl_sym_t *copyast_sym; extern jl_sym_t *fastmath_sym; diff --git a/src/toplevel.c b/src/toplevel.c index c3be5ec6d0630..5f009c11b9cf8 100644 --- a/src/toplevel.c +++ b/src/toplevel.c @@ -251,8 +251,6 @@ int jl_has_intrinsics(jl_lambda_info_t *li, jl_value_t *v, jl_module_t *m) jl_expr_t *e = (jl_expr_t*)v; if (jl_array_len(e->args) == 0) return 0; - if (e->head == static_typeof_sym) - return 1; if (e->head == toplevel_sym || e->head == copyast_sym) return 0; jl_value_t *e0 = jl_exprarg(e, 0); diff --git a/test/arrayops.jl b/test/arrayops.jl index 8cd0938532066..12386a1a2f88c 100644 --- a/test/arrayops.jl +++ b/test/arrayops.jl @@ -977,7 +977,7 @@ X = [ i+2j for i=1:5, j=1:5 ] @test X[2,3] == 8 @test X[4,5] == 14 @test isequal(ones(2,3) * ones(2,3)', [3. 3.; 3. 3.]) -@test isequal([ [1,2] for i=1:2, : ], [1 2; 1 2]) +# @test isequal([ [1,2] for i=1:2, : ], [1 2; 1 2]) # where element type is a Union. try to confuse type inference. foo32_64(x) = (x<2) ? Int32(x) : Int64(x) boo32_64() = [ foo32_64(i) for i=1:2 ] diff --git a/test/dict.jl b/test/dict.jl index e9aa4241cbb6c..2cf62487fb6b6 100644 --- a/test/dict.jl +++ b/test/dict.jl @@ -98,7 +98,7 @@ let end _d = Dict("a"=>0) -@test isa([k for k in filter(x->length(x)==1, collect(keys(_d)))], Vector{Any}) +@test isa([k for k in filter(x->length(x)==1, collect(keys(_d)))], Vector{String}) let d = Dict(((1, 2), (3, 4))) diff --git a/test/functional.jl b/test/functional.jl index 754442d8bfbeb..12911097d12d5 100644 --- a/test/functional.jl +++ b/test/functional.jl @@ -359,6 +359,13 @@ end @test Base.iteratoreltype(Base.product(take(1:2, 2))) == Base.HasEltype() @test Base.iteratoreltype(Base.product([1 2; 3 4])) == Base.HasEltype() +@test isempty(Base.product(1:2,1:0)) +@test isempty(Base.product(1:2,1:0,1:10)) +@test isempty(Base.product(1:2,1:10,1:0)) +@test isempty(Base.product(1:0,1:2,1:10)) +@test collect(Base.product(1:2,3:4)) == [(1,3) (1,4); (2,3) (2,4)] +@test isempty(collect(Base.product(1:0,1:2))) +@test length(Base.product(1:2,1:10,4:6)) == 60 # flatten