Skip to content

Commit

Permalink
disable "local declared twice" error
Browse files Browse the repository at this point in the history
This permits declaring a loop variable as local inside the loop,
which was used during 0.7 to get the new scope behavior.
  • Loading branch information
JeffBezanson committed Jul 31, 2018
1 parent fa6dbd3 commit cb39d36
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
4 changes: 2 additions & 2 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit cb39d36

Please sign in to comment.