Skip to content

Commit

Permalink
Merge pull request #16297 from stevengj/quote_eq_sym
Browse files Browse the repository at this point in the history
fix #16295: make sure :(==) is parenthesized in deprecation warnings
  • Loading branch information
vtjnash committed May 10, 2016
2 parents 1ddfa8e + cafcbde commit 7a65912
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1096,13 +1096,15 @@ end
#15032: Expressions like Base.(:+) now call broadcast. Since calls
# to broadcast(x, ::Symbol) are unheard of, and broadcast(x, ::Integer)
# are unlikely, we can treat these as deprecated getfield calls.
# (See julia-syntax.scm for the Base.(:+)(...) = ... deprecation.)
function broadcast(x::Any, i::Union{Integer,Symbol})
depwarn("x.(i) is deprecated; use getfield(x, i) instead.", :broadcast)
getfield(x, i)
end
# clearer to be more explicit in the warning for the Module case
function broadcast(m::Module, s::Symbol)
depwarn("$m.(:$s) is deprecated; use $m.:$s or getfield($m, :$s) instead.", :broadcast)
S = repr(s) # 16295
depwarn("$m.($S) is deprecated; use $m.$S or getfield($m, $S) instead.", :broadcast)
getfield(m, s)
end
# expressions like f.(3) should still call broadcast for f::Function,
Expand Down
3 changes: 2 additions & 1 deletion src/ast.scm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
((ref) (string (deparse (cadr e)) #\[ (deparse-arglist (cddr e)) #\]))
((curly) (string (deparse (cadr e)) #\{ (deparse-arglist (cddr e)) #\}))
((quote inert)
(if (symbol? (cadr e))
(if (and (symbol? (cadr e))
(not (= (string.char (string (cadr e)) 0) #\=)))
(string ":" (deparse (cadr e)))
(string ":(" (deparse (cadr e)) ")")))
((vect) (string #\[ (deparse-arglist (cdr e)) #\]))
Expand Down
7 changes: 4 additions & 3 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,10 @@
(s (if (symbol? s_) s_
(if (and (length= s_ 1) (symbol? (car s_))) (car s_) #f))))
(if s
(let ((newe (list (car e) (cadr e) (cadr (caddr e)))))
(syntax-deprecation #f (string (deparse (cadr e)) ".(:" s ")")
(string (deparse (cadr e)) ".:" s))
(let ((newe (list (car e) (cadr e) (cadr (caddr e))))
(S (deparse `(quote ,s)))) ; #16295
(syntax-deprecation #f (string (deparse (cadr e)) ".(" S ")")
(string (deparse (cadr e)) "." S))
newe)
e))
e))
Expand Down

0 comments on commit 7a65912

Please sign in to comment.