From 3439c9d68c94742e69f936b103f1ba96947fda7f Mon Sep 17 00:00:00 2001 From: Chris Foster Date: Sat, 27 Jul 2019 23:56:36 +1000 Subject: [PATCH] Simplify lowering of typed comprehension For implementing special syntax it's useful for typed comprehension to lower to `collect(T, gen)`. This changes typed comprehensions to use the same lowering pattern as normal comprehensions. Needed to tweak the precompile workaround from #28808 Co-authored-by: Andy Ferris --- contrib/generate_precompile.jl | 2 +- src/julia-syntax.scm | 12 +----------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/contrib/generate_precompile.jl b/contrib/generate_precompile.jl index c66ef3cdad954..f096f15c058a6 100644 --- a/contrib/generate_precompile.jl +++ b/contrib/generate_precompile.jl @@ -159,7 +159,7 @@ function generate_precompile_statements() include_time = @elapsed for statement in sort(collect(statements)) # println(statement) # Work around #28808 - occursin("\"YYYY-mm-dd\\THH:MM:SS\"", statement) && continue + occursin("\"YYYY-mm-dd\\THH:MM:SS", statement) && continue statement == "precompile(Tuple{typeof(Base.show), Base.IOContext{Base.TTY}, Type{Vararg{Any, N} where N}})" && continue try Base.include_string(PrecompileStagingArea, statement) diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index 381074c49bc7f..77604a377b5fe 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -2283,17 +2283,7 @@ 'typed_comprehension (lambda (e) - (expand-forms - (or (and (eq? (caaddr e) 'generator) - (let ((ranges (cddr (caddr e)))) - (if (any (lambda (x) (eq? x ':)) ranges) - (error "comprehension syntax with `:` ranges has been removed")) - (and (every (lambda (x) (and (pair? x) (eq? (car x) '=))) - ranges) - ;; TODO: this is a hack to lower simple comprehensions to loops very - ;; early, to greatly reduce the # of functions and load on the compiler - (lower-comprehension (cadr e) (cadr (caddr e)) ranges)))) - `(call (top collect) ,(cadr e) ,(caddr e))))))) + (expand-forms `(call (top collect) ,(cadr e) ,(caddr e)))))) (define (has-return? e) (expr-contains-p return? e (lambda (x) (not (function-def? x)))))