Skip to content

Commit

Permalink
small fix to the front end; avoid excessive rearrangement during cl-c…
Browse files Browse the repository at this point in the history
…onvert

this affects conditional definitions at the top level, e.g.

if cond
else
  type Foo; end
  g{T<:Foo}(x) = 0
end

we don't want to move the method def above the type def
  • Loading branch information
JeffBezanson committed Jan 28, 2016
1 parent 51d3ee5 commit 0b5e87a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -2904,13 +2904,18 @@ So far only the second case can actually occur.

(define (closure-convert e) (cl-convert e #f #f #f #f #f))

(define (toplevel-preserving? e)
(and (pair? e) (memq (car e) '(if block body trycatch))))

(define (map-cl-convert exprs fname lam namemap toplevel interp)
(if toplevel
(let loop ((exprs exprs)
(stmts '()))
(if (null? exprs)
(reverse! stmts)
(let* ((x (lift-toplevel (cl-convert (car exprs) fname lam namemap #f interp))))
(let* ((x (lift-toplevel (cl-convert (car exprs) fname lam namemap
(and toplevel (toplevel-preserving? (car exprs)))
interp))))
(loop (cdr exprs)
(cons (car x) (revappend (cdr x) stmts))))))
(map (lambda (x) (cl-convert x fname lam namemap #f interp)) exprs)))
Expand Down

0 comments on commit 0b5e87a

Please sign in to comment.