From cb39d36e91aebff347504072bc1e415180fa577e Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Mon, 30 Jul 2018 20:09:45 -0400 Subject: [PATCH] disable "local declared twice" error This permits declaring a loop variable as local inside the loop, which was used during 0.7 to get the new scope behavior. --- src/julia-syntax.scm | 2 +- test/syntax.jl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index dd45502a32e48..fa6b3fbed21d7 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -2366,7 +2366,7 @@ ;; pass 2: identify and rename local vars (define (check-dups locals others) - (if (pair? locals) + #;(if (pair? locals) (if (or (memq (car locals) (cdr locals)) (memq (car locals) others)) (error (string "local \"" (car locals) "\" declared twice")) (check-dups (cdr locals) others))) diff --git a/test/syntax.jl b/test/syntax.jl index c609309b517ab..23b6bf9682d01 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -521,7 +521,7 @@ end global x = 2 local x = 1 end")) == Expr(:error, "variable \"x\" declared both local and global") - +#= @test Meta.lower(Main, Meta.parse("let local x = 2 local x = 1 @@ -534,7 +534,7 @@ end @test Meta.lower(Main, Meta.parse("let x = 2 local x = 1 end")) == Expr(:error, "local \"x\" declared twice") - +=# # issue #23673 @test :(let $([:(x=1),:(y=2)]...); x+y end) == :(let x = 1, y = 2; x+y end)