From f5bf3317f04b907343f48412dc8a9a8bc43358a9 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Wed, 5 Sep 2018 17:50:34 -0400 Subject: [PATCH] fix #28991, error when adding default defs to constructed module Exprs (#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. (cherry picked from commit 11e32a44f259d46aafcc7f9feac10aaa241743e0) --- src/jlfrontend.scm | 11 +++++++---- test/syntax.jl | 8 ++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/jlfrontend.scm b/src/jlfrontend.scm index 8233a47feb3aa..77557c14ab682 100644 --- a/src/jlfrontend.scm +++ b/src/jlfrontend.scm @@ -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. diff --git a/test/syntax.jl b/test/syntax.jl index 250c73503a711..2090a1a5cfef0 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -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