Skip to content

Commit

Permalink
deprecate const on local variables, which used to be ignored.
Browse files Browse the repository at this point in the history
part of #5148
  • Loading branch information
JeffBezanson committed Aug 14, 2017
1 parent aecf426 commit 6257068
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ Language changes
(`need_to_handle_undef_sparam = Set{Any}(m.sig for m in Test.detect_unbound_args(Base, recursive=true))`)
is equal (`==`) to some known set (`expected = Set()`). ([#23117])

* `const` declarations on local variables were previously ignored. They now give a
warning, so that this syntax can be disallowed or given a new meaning in a
future version ([#5148]).

Breaking changes
----------------
Expand Down
15 changes: 9 additions & 6 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -3115,11 +3115,7 @@ f(x) = yt(x)
(if (vinfo:never-undef vi)
'(null)
`(newvar ,(cadr e))))))
((const)
(if (or (assq (cadr e) (car (lam:vinfo lam)))
(assq (cadr e) (cadr (lam:vinfo lam))))
'(null)
e))
((const) e)
((isdefined) ;; convert isdefined expr to function for closure converted variables
(let* ((sym (cadr e))
(vi (and (symbol? sym) (assq sym (car (lam:vinfo lam)))))
Expand Down Expand Up @@ -3661,7 +3657,14 @@ f(x) = yt(x)
((local-def) #f)
((local) #f)
((implicit-global) #f)
((const) (emit e))
((const)
(if (or (assq (cadr e) (car (lam:vinfo lam)))
(assq (cadr e) (cadr (lam:vinfo lam))))
(begin
(syntax-deprecation #f (string "`const` declaration on local variable" (linenode-string current-loc))
"")
'(null))
(emit e)))
((isdefined) (if tail (emit-return e) e))

;; top level expressions returning values
Expand Down

0 comments on commit 6257068

Please sign in to comment.