Skip to content

Commit

Permalink
add deprecation for x::T = 0 meaning typeassert if x is global
Browse files Browse the repository at this point in the history
also deprecates `global x::T` meaning a typeassert

also fix a bug where a type-assert was considered to be effect-free,
causing it to be quasi-converted into a local variable declaration

ref #964
  • Loading branch information
vtjnash committed Jul 21, 2016
1 parent dffc068 commit fe31a14
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion base/libuv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ show(io::IO, e::UVError) = print(io, e.prefix*": "*struverror(e)*" ("*uverrornam

## event loop ##

eventloop() = global uv_eventloop::Ptr{Void}
eventloop() = uv_eventloop::Ptr{Void}
#mkNewEventLoop() = ccall(:jl_new_event_loop,Ptr{Void},()) # this would probably be fine, but is nowhere supported

function run_event_loop()
Expand Down
20 changes: 9 additions & 11 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1321,16 +1321,11 @@
(define (remove-argument-side-effects e)
(let ((a '()))
(cond
((and (decl? e) (symbol? (cadr e)))
(cons (cadr e) (list e)))
((not (pair? e))
(cons e '()))
(else
(cons (map (lambda (x)
(cond
((and (decl? x) (symbol? (cadr x)))
(set! a (cons x a))
(cadr x))
((not (effect-free? x))
(let ((g (make-ssavalue)))
(if (or (eq? (car x) '...) (eq? (car x) '&))
Expand Down Expand Up @@ -1943,9 +1938,9 @@

'|::|
(lambda (e)
(if (length= e 2)
(if (not (length= e 3))
(error "invalid \"::\" syntax"))
(if (and (length= e 3) (not (symbol-like? (cadr e))))
(if (not (symbol-like? (cadr e)))
`(call (core typeassert)
,(expand-forms (cadr e)) ,(expand-forms (caddr e)))
(map expand-forms e)))
Expand Down Expand Up @@ -2915,10 +2910,13 @@ f(x) = yt(x)
;; remaining `decl` expressions are only type assertions if the
;; argument is global or a non-symbol.
((decl)
(if (or (assq (cadr e) (car (lam:vinfo lam)))
(assq (cadr e) (cadr (lam:vinfo lam))))
'(null)
(cl-convert `(call (core typeassert) ,@(cdr e)) fname lam namemap toplevel interp)))
(cond ((not (symbol? (cadr e)))
(cl-convert `(call (core typeassert) ,@(cdr e)) fname lam namemap toplevel interp))
((or (assq (cadr e) (car (lam:vinfo lam)))
(assq (cadr e) (cadr (lam:vinfo lam))))
'(null))
(else (syntax-deprecation #f (string "global " (deparse `(|::| ,@(cdr e)))) "typeassert")
(cl-convert `(call (core typeassert) ,@(cdr e)) fname lam namemap toplevel interp))))
;; `with-static-parameters` expressions can be removed now; used only by analyze-vars
((with-static-parameters)
(cl-convert (cadr e) fname lam namemap toplevel interp))
Expand Down

0 comments on commit fe31a14

Please sign in to comment.