Skip to content

Commit

Permalink
Simplify lowering of typed comprehension
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
c42f and andyferris committed Jul 29, 2019
1 parent 89b8057 commit 3439c9d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
2 changes: 1 addition & 1 deletion contrib/generate_precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 1 addition & 11 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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)))))
Expand Down

0 comments on commit 3439c9d

Please sign in to comment.