Skip to content

Commit

Permalink
fix #28991, error when adding default defs to constructed module Exprs (
Browse files Browse the repository at this point in the history
#29044)

The code for this expected the first element of a block to be a line
number; check to make sure it is before using it.
  • Loading branch information
JeffBezanson authored Sep 5, 2018
1 parent 1fb86d2 commit 11e32a4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/jlfrontend.scm
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,19 @@
(jl-expand-to-thunk
(let* ((name (caddr e))
(body (cadddr e))
(loc (cadr body))
(x (if (eq? name 'x) 'y 'x)))
(loc (cadr body))
(loc (if (and (pair? loc) (eq? (car loc) 'line))
(list loc)
'()))
(x (if (eq? name 'x) 'y 'x)))
`(block
(= (call eval ,x)
(block
,loc
,@loc
(call (core eval) ,name ,x)))
(= (call include ,x)
(block
,loc
,@loc
(call (top include) ,name ,x)))))))

;; parse only, returning end position, no expansion.
Expand Down
8 changes: 8 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,14 @@ end
@test Meta.isexpr(Meta.parse("1 == 2 ?"), :incomplete)
@test Meta.isexpr(Meta.parse("1 == 2 ? 3 :"), :incomplete)

# issue #28991
eval(Expr(:toplevel,
Expr(:module, true, :Mod28991,
Expr(:block,
Expr(:export, :Inner),
Expr(:abstract, :Inner)))))
@test names(Mod28991) == Symbol[:Inner, :Mod28991]

# issue #28593
macro a28593()
quote
Expand Down

0 comments on commit 11e32a4

Please sign in to comment.