Skip to content

Commit d283808

Browse files
committed
add deprecation for x::T = 0 meaning typeassert if x is global
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
1 parent 54a6490 commit d283808

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

base/libuv.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ show(io::IO, e::UVError) = print(io, e.prefix*": "*struverror(e)*" ("*uverrornam
7070

7171
## event loop ##
7272

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

7676
function run_event_loop()

src/julia-syntax.scm

+9-11
Original file line numberDiff line numberDiff line change
@@ -1321,16 +1321,11 @@
13211321
(define (remove-argument-side-effects e)
13221322
(let ((a '()))
13231323
(cond
1324-
((and (decl? e) (symbol? (cadr e)))
1325-
(cons (cadr e) (list e)))
13261324
((not (pair? e))
13271325
(cons e '()))
13281326
(else
13291327
(cons (map (lambda (x)
13301328
(cond
1331-
((and (decl? x) (symbol? (cadr x)))
1332-
(set! a (cons x a))
1333-
(cadr x))
13341329
((not (effect-free? x))
13351330
(let ((g (make-ssavalue)))
13361331
(if (or (eq? (car x) '...) (eq? (car x) '&))
@@ -1943,9 +1938,9 @@
19431938

19441939
'|::|
19451940
(lambda (e)
1946-
(if (length= e 2)
1941+
(if (not (length= e 3))
19471942
(error "invalid \"::\" syntax"))
1948-
(if (and (length= e 3) (not (symbol-like? (cadr e))))
1943+
(if (not (symbol-like? (cadr e)))
19491944
`(call (core typeassert)
19501945
,(expand-forms (cadr e)) ,(expand-forms (caddr e)))
19511946
(map expand-forms e)))
@@ -2915,10 +2910,13 @@ f(x) = yt(x)
29152910
;; remaining `decl` expressions are only type assertions if the
29162911
;; argument is global or a non-symbol.
29172912
((decl)
2918-
(if (or (assq (cadr e) (car (lam:vinfo lam)))
2919-
(assq (cadr e) (cadr (lam:vinfo lam))))
2920-
'(null)
2921-
(cl-convert `(call (core typeassert) ,@(cdr e)) fname lam namemap toplevel interp)))
2913+
(cond ((not (symbol? (cadr e)))
2914+
(cl-convert `(call (core typeassert) ,@(cdr e)) fname lam namemap toplevel interp))
2915+
((or (assq (cadr e) (car (lam:vinfo lam)))
2916+
(assq (cadr e) (cadr (lam:vinfo lam))))
2917+
'(null))
2918+
(else (syntax-deprecation #f (string "global " (deparse `(|::| ,@(cdr e)))) "typeassert")
2919+
(cl-convert `(call (core typeassert) ,@(cdr e)) fname lam namemap toplevel interp))))
29222920
;; `with-static-parameters` expressions can be removed now; used only by analyze-vars
29232921
((with-static-parameters)
29242922
(cl-convert (cadr e) fname lam namemap toplevel interp))

0 commit comments

Comments
 (0)