diff --git a/base/boot.jl b/base/boot.jl index 7b2758bb8d968..1cffd0107a7e2 100644 --- a/base/boot.jl +++ b/base/boot.jl @@ -142,7 +142,7 @@ export # key types - Any, DataType, Vararg, ANY, NTuple, + Any, DataType, Vararg, NTuple, Tuple, Type, UnionAll, TypeVar, Union, Nothing, Cvoid, AbstractArray, DenseArray, NamedTuple, # special objects diff --git a/base/char.jl b/base/char.jl index 359a3013ecfa1..700c61db27c77 100644 --- a/base/char.jl +++ b/base/char.jl @@ -119,8 +119,8 @@ function UInt32(c::Char) invalid_char(c)::Union{} u &= 0xffffffff >> l1 u >>= t0 - (u & 0x0000007f >> 0) | (u & 0x00007f00 >> 2) | - (u & 0x007f0000 >> 4) | (u & 0x7f000000 >> 6) + ((u & 0x0000007f) >> 0) | ((u & 0x00007f00) >> 2) | + ((u & 0x007f0000) >> 4) | ((u & 0x7f000000) >> 6) end function decode_overlong(c::Char) @@ -129,8 +129,8 @@ function decode_overlong(c::Char) t0 = trailing_zeros(u) & 56 u &= 0xffffffff >> l1 u >>= t0 - (u & 0x0000007f >> 0) | (u & 0x00007f00 >> 2) | - (u & 0x007f0000 >> 4) | (u & 0x7f000000 >> 6) + ((u & 0x0000007f) >> 0) | ((u & 0x00007f00) >> 2) | + ((u & 0x007f0000) >> 4) | ((u & 0x7f000000) >> 6) end """ diff --git a/base/deprecated.jl b/base/deprecated.jl index da3022ca95557..0d5bab723c815 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -364,15 +364,6 @@ end # nfields(::Type) deprecation in builtins.c: update nfields tfunc in compiler/tfuncs.jl when it is removed. # also replace `_nfields` with `nfields` in summarysize.c when this is removed. -# ::ANY is deprecated in src/method.c -# also remove all instances of `jl_ANY_flag` in src/ - -# issue #13079 -# in julia-parser.scm: -# move prec-bitshift after prec-rational -# remove parse-with-chains-warn and bitshift-warn -# update precedence table in doc/src/manual/mathematical-operations.md - # PR #22182 @deprecate is_apple Sys.isapple @deprecate is_bsd Sys.isbsd @@ -397,9 +388,6 @@ end @deprecate_binding UVError IOError false -# issue #11310 -# remove "parametric method syntax" deprecation in julia-syntax.scm - @deprecate momenttype(::Type{T}) where {T} typeof((zero(T)*zero(T) + zero(T)*zero(T))/2) false # issue #6466 @@ -488,9 +476,6 @@ end # issue #5148, PR #23259 # warning for `const` on locals should be changed to an error in julia-syntax.scm -# issue #22789 -# remove code for `importall` in src/ - # issue #17886 # deprecations for filter[!] with 2-arg functions are in abstractdict.jl @@ -1720,7 +1705,6 @@ function factorial(x::Number) end # issue #27093 -# in src/jlfrontend.scm a call to `@deprecate` is generated for per-module `eval(m, x)` @eval Core Main.Base.@deprecate(eval(e), Core.eval(Main, e)) @eval @deprecate $(Symbol("@schedule")) $(Symbol("@async")) diff --git a/base/essentials.jl b/base/essentials.jl index 603c5248843b2..07aed1c1fcab8 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -325,11 +325,6 @@ oftype(x, y) = convert(typeof(x), y) unsigned(x::Int) = reinterpret(UInt, x) signed(x::UInt) = reinterpret(Int, x) -# conversions used by ccall -ptr_arg_cconvert(::Type{Ptr{T}}, x) where {T} = cconvert(T, x) -ptr_arg_unsafe_convert(::Type{Ptr{T}}, x) where {T} = unsafe_convert(T, x) -ptr_arg_unsafe_convert(::Type{Ptr{Cvoid}}, x) = x - """ cconvert(T,x) diff --git a/base/hashing2.jl b/base/hashing2.jl index 77a7d4e2accaa..196d3cd06e0ea 100644 --- a/base/hashing2.jl +++ b/base/hashing2.jl @@ -101,7 +101,7 @@ function decompose(x::Float16)::NTuple{3,Int} isinf(x) && return ifelse(x < 0, -1, 1), 0, 0 n = reinterpret(UInt16, x) s = (n & 0x03ff) % Int16 - e = (n & 0x7c00 >> 10) % Int + e = ((n & 0x7c00) >> 10) % Int s |= Int16(e != 0) << 10 d = ifelse(signbit(x), -1, 1) s, e - 25 + (e == 0), d @@ -112,7 +112,7 @@ function decompose(x::Float32)::NTuple{3,Int} isinf(x) && return ifelse(x < 0, -1, 1), 0, 0 n = reinterpret(UInt32, x) s = (n & 0x007fffff) % Int32 - e = (n & 0x7f800000 >> 23) % Int + e = ((n & 0x7f800000) >> 23) % Int s |= Int32(e != 0) << 23 d = ifelse(signbit(x), -1, 1) s, e - 150 + (e == 0), d @@ -123,7 +123,7 @@ function decompose(x::Float64)::Tuple{Int64, Int, Int} isinf(x) && return ifelse(x < 0, -1, 1), 0, 0 n = reinterpret(UInt64, x) s = (n & 0x000fffffffffffff) % Int64 - e = (n & 0x7ff0000000000000 >> 52) % Int + e = ((n & 0x7ff0000000000000) >> 52) % Int s |= Int64(e != 0) << 52 d = ifelse(signbit(x), -1, 1) s, e - 1075 + (e == 0), d diff --git a/doc/src/manual/mathematical-operations.md b/doc/src/manual/mathematical-operations.md index 456146a4aed4d..6d451ea00c722 100644 --- a/doc/src/manual/mathematical-operations.md +++ b/doc/src/manual/mathematical-operations.md @@ -356,11 +356,11 @@ Julia applies the following order and associativity of operations, from highest |:-------------- |:------------------------------------------------------------------------------------------------- |:-------------------------- | | Syntax | `.` followed by `::` | Left | | Exponentiation | `^` | Right | -| Unary | `+ - √` | Right[^1] | -| Fractions | `//` | Left | -| Multiplication | `* / % & \ ÷` | Left[^2] | +| Unary | `+ - √` | Right[^1] | | Bitshifts | `<< >> >>>` | Left | -| Addition | `+ - \| ⊻` | Left[^2] | +| Fractions | `//` | Left | +| Multiplication | `* / % & \ ÷` | Left[^2] | +| Addition | `+ - \| ⊻` | Left[^2] | | Syntax | `: ..` | Left | | Syntax | `\|>` | Left | | Syntax | `<\|` | Right | diff --git a/src/ast.c b/src/ast.c index cc66b419726f7..59ba152bd2d39 100644 --- a/src/ast.c +++ b/src/ast.c @@ -30,8 +30,7 @@ jl_sym_t *call_sym; jl_sym_t *invoke_sym; jl_sym_t *empty_sym; jl_sym_t *top_sym; jl_sym_t *module_sym; jl_sym_t *slot_sym; jl_sym_t *export_sym; jl_sym_t *import_sym; -jl_sym_t *importall_sym; jl_sym_t *toplevel_sym; -jl_sym_t *quote_sym; jl_sym_t *amp_sym; +jl_sym_t *toplevel_sym; jl_sym_t *quote_sym; jl_sym_t *line_sym; jl_sym_t *jl_incomplete_sym; jl_sym_t *goto_sym; jl_sym_t *goto_ifnot_sym; jl_sym_t *return_sym; jl_sym_t *unreachable_sym; @@ -334,7 +333,6 @@ void jl_init_frontend(void) export_sym = jl_symbol("export"); import_sym = jl_symbol("import"); using_sym = jl_symbol("using"); - importall_sym = jl_symbol("importall"); assign_sym = jl_symbol("="); method_sym = jl_symbol("method"); exc_sym = jl_symbol("the_exception"); @@ -344,7 +342,6 @@ void jl_init_frontend(void) const_sym = jl_symbol("const"); global_sym = jl_symbol("global"); thunk_sym = jl_symbol("thunk"); - amp_sym = jl_symbol("&"); abstracttype_sym = jl_symbol("abstract_type"); primtype_sym = jl_symbol("primitive_type"); structtype_sym = jl_symbol("struct_type"); diff --git a/src/ast.scm b/src/ast.scm index 7ceb85fcd9562..4b37019640cad 100644 --- a/src/ast.scm +++ b/src/ast.scm @@ -81,7 +81,7 @@ (string #\( (deparse (caddr e)) " " (cadr e) " " (deparse (cadddr e)) #\) )) (else (deparse-prefix-call (cadr e) (cddr e) #\( #\))))) - (($ &) (if (pair? (cadr e)) + (($ &) (if (and (pair? (cadr e)) (not (eq? (caadr e) 'outerref))) (string (car e) "(" (deparse (cadr e)) ")") (string (car e) (deparse (cadr e))))) ((|::|) (if (length= e 2) @@ -200,7 +200,7 @@ (string.join (map deparse (cdr (cadddr e))) "\n") "\n" "end")) ;; misc syntax forms - ((import importall using) + ((import using) (define (deparse-path e) (cond ((and (pair? e) (eq? (car e) '|.|)) (let loop ((lst (cdr e)) diff --git a/src/builtins.c b/src/builtins.c index 6442a34652cc1..536f22b3b1945 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -294,13 +294,6 @@ static uintptr_t jl_object_id_(jl_value_t *tv, jl_value_t *v) } if (dt == jl_typename_type) return ((jl_typename_t*)v)->hash; -#ifdef _P64 - if (v == jl_ANY_flag) - return 0x31c472f68ee30bddULL; -#else - if (v == jl_ANY_flag) - return 0x8ee30bdd; -#endif if (dt == jl_string_type) { #ifdef _P64 return memhash_seed(jl_string_data(v), jl_string_len(v), 0xedc3b677); @@ -1328,8 +1321,6 @@ void jl_init_primitives(void) add_builtin("AbstractString", (jl_value_t*)jl_abstractstring_type); add_builtin("String", (jl_value_t*)jl_string_type); - - add_builtin("ANY", jl_ANY_flag); } #ifdef __cplusplus diff --git a/src/ccall.cpp b/src/ccall.cpp index e52a57acbb5f0..23e8d1c3ad980 100644 --- a/src/ccall.cpp +++ b/src/ccall.cpp @@ -1560,14 +1560,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs) // Julia (expression) value of current parameter jl_value_t *argi = ccallarg(i); - // pass the address of the argument rather than the argument itself - if (jl_is_expr(argi) && ((jl_expr_t*)argi)->head == amp_sym) { - addressOf.push_back(true); - argi = jl_exprarg(argi, 0); - } - else { - addressOf.push_back(false); - } + addressOf.push_back(false); argv[i] = emit_expr(ctx, argi); } diff --git a/src/dump.c b/src/dump.c index bd82b0237bfad..8b250bc1df71d 100644 --- a/src/dump.c +++ b/src/dump.c @@ -3180,7 +3180,7 @@ void jl_init_serializer(void) jl_pointer_type, jl_vararg_type, jl_abstractarray_type, jl_void_type, jl_densearray_type, jl_function_type, jl_typename_type, jl_builtin_type, jl_task_type, jl_uniontype_type, jl_typetype_type, - jl_ANY_flag, jl_array_any_type, jl_intrinsic_type, + jl_array_any_type, jl_intrinsic_type, jl_abstractslot_type, jl_methtable_type, jl_typemap_level_type, jl_voidpointer_type, jl_newvarnode_type, jl_abstractstring_type, jl_array_symbol_type, jl_anytuple_type, jl_tparam0(jl_anytuple_type), diff --git a/src/gc.c b/src/gc.c index 95e68a933d278..878fb4f479952 100644 --- a/src/gc.c +++ b/src/gc.c @@ -2267,7 +2267,6 @@ static void mark_roots(jl_gc_mark_cache_t *gc_cache, gc_mark_sp_t *sp) if (jl_cfunction_list != NULL) gc_mark_queue_obj(gc_cache, sp, jl_cfunction_list); gc_mark_queue_obj(gc_cache, sp, jl_anytuple_type_type); - gc_mark_queue_obj(gc_cache, sp, jl_ANY_flag); for (size_t i = 0; i < N_CALL_CACHE; i++) if (call_cache[i]) gc_mark_queue_obj(gc_cache, sp, call_cache[i]); diff --git a/src/jlfrontend.scm b/src/jlfrontend.scm index a72e2b5d84a2c..deae29f64618c 100644 --- a/src/jlfrontend.scm +++ b/src/jlfrontend.scm @@ -109,7 +109,7 @@ (define (toplevel-only-expr? e) (and (pair? e) - (or (memq (car e) '(toplevel line module import importall using export + (or (memq (car e) '(toplevel line module import using export error incomplete)) (and (eq? (car e) 'global) (every symbol? (cdr e)) (every (lambda (x) (not (memq x '(true false)))) (cdr e)))))) @@ -140,15 +140,6 @@ (block ,loc (call (core eval) ,name ,x))) - (if (&& (call (top isdefined) (core Main) (quote Base)) - (call (top isdefined) (|.| (core Main) (quote Base)) (quote @deprecate))) - (call eval - (quote - (macrocall (|.| (|.| (core Main) (quote Base)) (quote @deprecate)) - (line 0 none) - (call eval m x) - (call (|.| Core (quote eval)) m x) ; should be (core eval), but format as Core.eval(m, x) for deprecation warning - false)))) (= (call include ,x) (block ,loc @@ -267,14 +258,21 @@ ((length= lno 2) `(,(cadr lno) none)) (else (cdr lno)))) +(define (format-loc lno) + (let* ((lf (extract-line-file lno)) (line (car lf)) (file (cadr lf))) + (format-file-line file line #f))) + +(define (format-file-line file line exactloc) + (if (or (= line 0) (eq? file 'none)) + "" + (string (if exactloc " at " " around ") file ":" line))) + (define (format-syntax-deprecation what instead file line exactloc) (string "Deprecated syntax `" what "`" - (if (or (= line 0) (eq? file 'none)) - "" - (string (if exactloc " at " " around ") file ":" line)) + (format-file-line file line exactloc) "." (if (equal? instead "") "" - (string #\newline "Use `" instead "` instead.")))) + (string #\newline "Use `" instead "` instead.")))) ; Corresponds to --depwarn 0="no", 1="yes", 2="error" (define *depwarn-opt* 1) diff --git a/src/jltypes.c b/src/jltypes.c index b566df7f64b41..9a1f6a42b6449 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -75,7 +75,6 @@ JL_DLLEXPORT jl_value_t *jl_true; JL_DLLEXPORT jl_value_t *jl_false; jl_unionall_t *jl_typetype_type; -jl_value_t *jl_ANY_flag; jl_unionall_t *jl_array_type; jl_typename_t *jl_array_typename; @@ -2168,8 +2167,6 @@ void jl_init_types(void) (jl_unionall_t*)jl_new_struct(jl_unionall_type, typetype_tvar, jl_apply_type1((jl_value_t*)jl_type_type, (jl_value_t*)typetype_tvar)); - jl_ANY_flag = (jl_value_t*)tvar("ANY"); - jl_abstractstring_type = jl_new_abstracttype((jl_value_t*)jl_symbol("AbstractString"), core, jl_any_type, jl_emptysvec); jl_string_type = jl_new_datatype(jl_symbol("String"), core, jl_abstractstring_type, jl_emptysvec, jl_emptysvec, jl_emptysvec, 0, 1, 0); diff --git a/src/julia-parser.scm b/src/julia-parser.scm index ce7eca518ed01..78066231654ec 100644 --- a/src/julia-parser.scm +++ b/src/julia-parser.scm @@ -25,9 +25,9 @@ (define prec-colon (append! '(: |..|) (add-dots '(… ⁝ ⋮ ⋱ ⋰ ⋯)))) (define prec-plus (append! '($) (add-dots '(+ - |\|| ⊕ ⊖ ⊞ ⊟ |++| ∪ ∨ ⊔ ± ∓ ∔ ∸ ≂ ≏ ⊎ ⊻ ⊽ ⋎ ⋓ ⧺ ⧻ ⨈ ⨢ ⨣ ⨤ ⨥ ⨦ ⨧ ⨨ ⨩ ⨪ ⨫ ⨬ ⨭ ⨮ ⨹ ⨺ ⩁ ⩂ ⩅ ⩊ ⩌ ⩏ ⩐ ⩒ ⩔ ⩖ ⩗ ⩛ ⩝ ⩡ ⩢ ⩣)))) -(define prec-bitshift (add-dots '(<< >> >>>))) (define prec-times (add-dots '(* / ÷ % & ⋅ ∘ × |\\| ∩ ∧ ⊗ ⊘ ⊙ ⊚ ⊛ ⊠ ⊡ ⊓ ∗ ∙ ∤ ⅋ ≀ ⊼ ⋄ ⋆ ⋇ ⋉ ⋊ ⋋ ⋌ ⋏ ⋒ ⟑ ⦸ ⦼ ⦾ ⦿ ⧶ ⧷ ⨇ ⨰ ⨱ ⨲ ⨳ ⨴ ⨵ ⨶ ⨷ ⨸ ⨻ ⨼ ⨽ ⩀ ⩃ ⩄ ⩋ ⩍ ⩎ ⩑ ⩓ ⩕ ⩘ ⩚ ⩜ ⩞ ⩟ ⩠ ⫛ ⊍ ▷ ⨝ ⟕ ⟖ ⟗))) (define prec-rational (add-dots '(//))) +(define prec-bitshift (add-dots '(<< >> >>>))) ;; `where` ;; implicit multiplication (juxtaposition) ;; unary @@ -41,7 +41,6 @@ prec-pipe< prec-pipe> prec-colon prec-plus prec-bitshift prec-times prec-rational prec-power prec-decl prec-dot)) -(define trans-op (string->symbol ".'")) (define ctrans-op (string->symbol "'")) (define vararg-op (string->symbol "...")) @@ -66,7 +65,7 @@ (define no-suffix? (Set (append prec-assignment prec-conditional prec-lazy-or prec-lazy-and prec-colon prec-decl prec-dot '(-- --> -> |<:| |>:| in isa $) - (list ctrans-op trans-op vararg-op)))) + (list ctrans-op vararg-op)))) (define (maybe-strip-op-suffix op) (if (symbol? op) (let ((op_ (strip-op-suffix op))) @@ -130,7 +129,7 @@ (define operators (filter (lambda (x) (not (is-word-operator? x))) (delete-duplicates - (list* '-> ctrans-op trans-op vararg-op + (list* '-> ctrans-op vararg-op (append unary-ops (apply append (map eval prec-names))))))) (define op-chars @@ -150,7 +149,6 @@ (define initial-reserved-words '(begin while if for try return break continue function macro quote let local global const do struct - type immutable importall ;; to be deprecated module baremodule using import export)) (define initial-reserved-word? (Set initial-reserved-words)) @@ -180,8 +178,6 @@ (define whitespace-newline #f) ; enable parsing `where` with high precedence (define where-enabled #t) -; allow (x...), parsed as (... x). otherwise a deprecation warning is given (#24452) -(define accept-dots-without-comma #f) (define current-filename 'none) @@ -380,11 +376,7 @@ (or (eq? pred char-bin?) (eq? pred char-oct?) (and (eq? pred char-hex?) (not is-hex-float-literal))) (or (char-numeric? c) - (and (identifier-start-char? c) - (parser-depwarn port ;; remove after v0.7 - (string (get-output-string str) c) - (string (get-output-string str) " * " c)) - #f))) ;; remove after v0.7 + (identifier-start-char? c))) ;; disallow digits after binary or octal literals, e.g., 0b12 ;; and disallow identifier chars after hex literals. (error (string "invalid numeric constant \"" @@ -783,20 +775,20 @@ (let ((ex (parse-arrow s))) (cond ((eq? (peek-token s) '?) (begin (if (not (ts:space? s)) - (parser-depwarn s (string (deparse ex) "?") (string (deparse ex) " ?"))) + (error "space required before \"?\" operator")) (take-token s) ; take the ? (let ((t (with-whitespace-newline (without-range-colon (peek-token s))))) (if (not (ts:space? s)) - (parser-depwarn s (string (deparse ex) " ?" (deparse t)) (string (deparse ex) " ? " (deparse t))))) + (error "space required after \"?\" operator"))) (let ((then (without-range-colon (parse-eq* s)))) (if (not (eq? (peek-token s) ':)) (error "colon expected in \"?\" expression")) (if (not (ts:space? s)) - (parser-depwarn s (string (deparse ex) " ? " (deparse then) ":") (string (deparse ex) " ? " (deparse then) " :"))) + (error "space required before colon in \"?\" expression")) (take-token s) ; take the : (let ((t (with-whitespace-newline (peek-token s)))) (if (not (ts:space? s)) - (parser-depwarn s (string (deparse ex) " ? " (deparse then) " :" t) (string (deparse ex) " ? " (deparse then) " : " t)))) + (error "space required after colon in \"?\" expression"))) (list 'if ex then (parse-eq* s))))) (else ex)))) @@ -903,49 +895,10 @@ (else (loop (list 'call t ex (down s)))))))))) -(define (parse-with-chains-warn s down ops chain-ops) - (let loop ((ex (down s)) - (got #f)) - (let ((t (peek-token s))) - (if (not (ops t)) - (cons ex got) - (let ((spc (ts:space? s))) - (take-token s) - (cond ((and space-sensitive spc (memq t unary-and-binary-ops) - (not (eqv? (peek-char (ts:port s)) #\ ))) - ;; here we have "x -y" - (ts:put-back! s t spc) - (cons ex got)) - ((memq t chain-ops) - (loop (list* 'call t ex - (parse-chain s down t)) - #t)) - (else - (loop (list 'call t ex (down s)) - got)))))))) - -(define (parse-expr s) (parse-with-chains s parse-shift is-prec-plus? '(+ ++))) - -(define (bitshift-warn s) - (parser-depwarn s (string "call to `*` inside call to bitshift operator") - "parenthesized call to `*`")) - -(define (parse-shift s) #;(parse-LtoR s parse-term is-prec-bitshift?) - (let loop ((ex (parse-term s)) - (t (peek-token s)) - (warn1 #f)) - (let ((ex (car ex)) - (warn (cdr ex))) - (if (is-prec-bitshift? t) - (begin (if warn (bitshift-warn s)) - (take-token s) - (let ((nxt (parse-term s))) - (loop (cons (list 'call t ex (car nxt)) (cdr nxt)) (peek-token s) (cdr nxt)))) - (begin (if warn1 (bitshift-warn s)) - ex))))) - -(define (parse-term s) (parse-with-chains-warn s parse-rational is-prec-times? '(*))) -(define (parse-rational s) (parse-LtoR s parse-unary-subtype is-prec-rational?)) +(define (parse-expr s) (parse-with-chains s parse-term is-prec-plus? '(+ ++))) +(define (parse-term s) (parse-with-chains s parse-rational is-prec-times? '(*))) +(define (parse-rational s) (parse-LtoR s parse-shift is-prec-rational?)) +(define (parse-shift s) (parse-LtoR s parse-unary-subtype is-prec-bitshift?)) ;; parse `<: A where B` as `<: (A where B)` (issue #21545) (define (parse-unary-subtype s) @@ -1089,8 +1042,7 @@ ((eqv? next #\( ) (take-token s) (let* ((opspc (ts:space? s)) - (parens (with-bindings ((accept-dots-without-comma #t)) - (parse-paren- s #t)))) + (parens (parse-paren- s #t))) (if (cdr parens) ;; found an argument list (if opspc (disallowed-space op #\( ) @@ -1102,8 +1054,7 @@ ((not un) (error (string "\"" op "\" is not a unary operator"))) (else - (let ((arg (with-bindings ((accept-dots-without-comma #t)) - (parse-unary s)))) + (let ((arg (parse-unary s))) (fix-syntactic-unary (list op arg))))))) (define block-form? (Set '(block quote if for while let function macro abstract primitive struct @@ -1161,14 +1112,11 @@ (or (closing-token? next) (newline? next)))) op) ((memq op '(& |::|)) (list op (parse-where s parse-call))) - (else (list op (with-bindings - ((accept-dots-without-comma #t)) - (parse-unary-prefix s)))))) + (else (list op (parse-unary-prefix s))))) (parse-atom s)))) (define (parse-def s is-func anon) - (let* ((ex (with-bindings ((accept-dots-without-comma anon)) - (parse-unary-prefix s))) + (let* ((ex (parse-unary-prefix s)) (sig (if (or (and is-func (reserved-word? ex)) (initial-reserved-word? ex)) (error (string "invalid name \"" ex "\"")) (parse-call-chain s ex #f))) @@ -1267,7 +1215,7 @@ `(macrocall (|.| ,ex (quote ,(cadr name))) ; move macrocall outside by rewriting A.@B as @A.B ,@(cddr name)) `(|.| ,ex (quote ,name)))))))) - ((|.'| |'|) + ((|'|) (if (ts:space? s) (error (string "space not allowed before \"" t "\""))) (take-token s) @@ -1497,13 +1445,6 @@ (nb (with-space-sensitive (parse-cond s)))) (begin0 (list 'primitive spec nb) (expect-end (take-lineendings s) "primitive type")))))) - ;; deprecated type keywords - ((type) - (parser-depwarn s "type" "mutable struct") ;; retain in 0.7 - (parse-struct-def s #t word)) - ((immutable) - (parser-depwarn s "immutable" "struct") ;; retain in 0.7 - (parse-struct-def s #f word)) ((try) (let ((try-block (if (memq (require-token s) '(catch finally)) @@ -1517,9 +1458,7 @@ (cond ((eq? nxt 'end) (list* 'try try-block (or catchv 'false) - ;; default to empty catch block in `try ... end` - (or catchb (if finalb 'false (begin (parser-depwarn s "try without catch or finally" "") - '(block)))) + (or catchb (if finalb 'false (error "try without catch or finally"))) (if finalb (list finalb) '()))) ((and (eq? nxt 'catch) (not catchb)) @@ -1536,9 +1475,7 @@ (var? (and (not nl) (or (and (symbol? var) (not (eq? var 'false)) (not (eq? var 'true))) (and (length= var 2) (eq? (car var) '$)) - (and (parser-depwarn s (string "catch " (deparse var) "") - (string "catch; " (deparse var) "")) - #f)))) + (error (string "invalid syntax \"catch " (deparse var) "\""))))) (catch-block (if (eq? (require-token s) 'finally) `(block ,(line-number-node s)) (parse-block s)))) @@ -1589,7 +1526,7 @@ (if (not (every symbol-or-interpolate? es)) (error "invalid \"export\" statement")) `(export ,@es))) - ((import using importall) + ((import using) (parse-imports s word)) ((do) (error "invalid \"do\" syntax")) @@ -1816,12 +1753,7 @@ (if (eqv? (require-token s) closer) (loop lst nxt) (let ((params (parse-call-arglist s closer))) - (if (or (null? params) (equal? params '((parameters)))) - (begin (parser-depwarn s (deparse `(vect (parameters) ,@(reverse lst) ,nxt)) - (deparse `(vcat ,@(reverse lst) ,nxt))) - ;; TODO: post 0.7, remove deprecation and change parsing to 'vect - `(vcat ,@(reverse lst) ,nxt)) - `(vect ,@params ,@(reverse lst) ,nxt))))) + `(vect ,@params ,@(reverse lst) ,nxt)))) ((#\] #\}) (error (string "unexpected \"" t "\""))) (else @@ -2034,15 +1966,7 @@ (take-token s) ;; value in parentheses (x) (if (vararg? ex) - (let ((lineno (input-port-line (ts:port s)))) - (if (or accept-dots-without-comma (eq? (with-bindings ((whitespace-newline #f)) - (peek-token s)) - '->)) - (cons ex #t) - (begin (parser-depwarn lineno - (string "(" (deparse (cadr ex)) "...)") - (string "(" (deparse (cadr ex)) "...,)")) - (cons `(tuple ,ex) #t)))) + (cons ex #t) (cons ex #f))) ((eqv? t #\,) ;; tuple (x,) (x,y) etc. @@ -2294,10 +2218,8 @@ (read (open-input-string (string #\" s #\")))))) (define-macro (check-identifier ex) - `(begin (if (or (syntactic-op? ,ex) (eq? ,ex '....)) - (error (string "invalid identifier name \"" ,ex "\""))) - (if (eq? ,ex '?) - (parser-depwarn s "`?` used as an identifier" "")))) ; merge with above check in v1.0 + `(if (or (syntactic-op? ,ex) (eq? ,ex '....) (eq? ,ex '?)) + (error (string "invalid identifier name \"" ,ex "\"")))) ;; parse numbers, identifiers, parenthesized expressions, lists, vectors, etc. (define (parse-atom s (checked #t)) @@ -2454,19 +2376,16 @@ (if (and (length= e 4) (eq? (called-macro-name (cadr e)) '@doc)) (let ((arg (cadddr e))) - (if (and (pair? arg) (eq? (car arg) '->)) - (begin (parser-depwarn s "@doc call with ->" "a line break") - e) - (let loop ((t (peek-token s)) - (nl 0)) - (cond ((closing-token? t) e) - ((newline? t) - (if (> nl 0) - e - (begin (take-token s) - (loop (peek-token s) 1)))) - (else - `(,@e ,(parse-eq s))))))) + (let loop ((t (peek-token s)) + (nl 0)) + (cond ((closing-token? t) e) + ((newline? t) + (if (> nl 0) + e + (begin (take-token s) + (loop (peek-token s) 1)))) + (else + `(,@e ,(parse-eq s)))))) e)) (define (simple-string-literal? e) (string? e)) @@ -2474,13 +2393,8 @@ (define (doc-string-literal? s e) (or (simple-string-literal? e) (and (pair? e) - (or (eq? (car e) 'string) ; string interpolation - (and (eq? (car e) 'macrocall) - (or (and (length= e 3) (simple-string-literal? (caddr e))) - (and (length= e 4) (simple-string-literal? (cadddr e)))) - (eq? (cadr e) '@doc_str) - (begin (parser-depwarn s "doc\" \"" "@doc doc\" \"") - #t)))))) + ;; string interpolation + (eq? (car e) 'string)))) (define (parse-docstring s production) (let ((startloc (line-number-node s)) ; be sure to use the line number from the head of the docstring @@ -2491,11 +2405,7 @@ (cond ((closing-token? t) #f) ((newline? t) (if (= nl 1) - ;;#f ;; extra line => not a doc string. enable when deprecation is removed. - (begin (parser-depwarn s "multiple line breaks between doc string and object" - "at most one line break") - (take-token s) - (loop (peek-token s) 2)) + #f ;; extra line => not a doc string (begin (take-token s) (loop (peek-token s) 1)))) (else #t)))) diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index dfab3f820d594..cfee5aba2d64e 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -518,17 +518,7 @@ (let ((T (caddr v))) `(call (core typeassert) ,rval0 - ;; work around `ANY` not being a type. if arg type - ;; looks like `ANY`, test whether it is `ANY` at run - ;; time and if so, substitute `Any`. issue #21510 - ,(if (or (eq? T 'ANY) - (and (globalref? T) - (eq? (caddr T) 'ANY))) - `(call (core ifelse) - (call (core ===) ,T (core ANY)) - (core Any) - ,T) - T))) + ,T)) rval0))) `(if (call (top haskey) ,kw (quote ,k)) ,rval @@ -948,16 +938,14 @@ (let* ((a (car A)) (isseq (and (vararg? (car F)))) (ty (if isseq (cadar F) (car F)))) - (if (and isseq (not (null? (cdr F)))) (error "only the trailing ccall argument type should have '...'")) + (if (and isseq (not (null? (cdr F)))) (error "only the trailing ccall argument type should have \"...\"")) (if (eq? ty 'Any) (loop (if isseq F (cdr F)) (cdr A) stmts (list* a C) GC) (let* ((g (make-ssavalue)) - (isamp (and (pair? a) (eq? (car a) '&))) - (a (if isamp (cadr a) a)) - (stmts (cons `(= ,g (call (top ,(if isamp 'ptr_arg_cconvert 'cconvert)) ,ty ,a)) stmts)) - (ca `(call (top ,(if isamp 'ptr_arg_unsafe_convert 'unsafe_convert)) ,ty ,g))) + (stmts (cons `(= ,g (call (top cconvert) ,ty ,a)) stmts)) + (ca `(call (top unsafe_convert) ,ty ,g))) (loop (if isseq F (cdr F)) (cdr A) stmts - (list* (if isamp `(& ,ca) ca) C) (list* g GC)))))))) + (list* ca C) (list* g GC)))))))) (define (expand-function-def e) ;; handle function definitions (define (just-arglist? ex) @@ -1027,8 +1015,7 @@ ((eq? (car name) 'call) (let* ((head (cadr name)) (argl (cddr name)) - (has-sp (and (not where) (pair? head) (eq? (car head) 'curly))) - (name (deprecate-dotparen (if has-sp (cadr head) head))) + (name (deprecate-dotparen head)) (op (let ((op_ (maybe-undotop name))) ; handle .op -> broadcast deprecation (if op_ (syntax-deprecation (string "function " (deparse name) "(...)") @@ -1042,9 +1029,7 @@ (if (nospecialize-meta? a) (caddr a) a)) argl)) (argl (if op (cons `(|::| (call (core Typeof) ,op)) argl) argl)) - (raw-typevars (cond (has-sp (cddr head)) - (where where) - (else '()))) + (raw-typevars (or where '())) (sparams (map analyze-typevar raw-typevars)) (adj-decl (lambda (n) (if (and (decl? n) (length= n 2)) `(|::| |#self#| ,(cadr n)) @@ -1063,15 +1048,6 @@ (eq? (caar argl) 'parameters)))))) (name (if (or (decl? name) (and (pair? name) (eq? (car name) 'curly))) #f name))) - (if has-sp - (syntax-deprecation (string "parametric method syntax " (deparse (cadr e))) - (deparse `(where (call ,(or name - (cadr (cadr (cadr e)))) - ,@(if (has-parameters? argl) - (cons (car argl) (cddr argl)) - (cdr argl))) - ,@raw-typevars)) - (function-body-lineno body))) (expand-forms (method-def-expr name sparams argl body rett)))) (else @@ -1108,14 +1084,6 @@ (list (cadr e)))) (define (expand-let e) - (if (length= e 2) - (begin (deprecation-message (string "The form `Expr(:let, ex)` is deprecated. " - "Use `Expr(:let, Expr(:block), ex)` instead." #\newline) #f) - (return (expand-let `(let (block) ,(cadr e)))))) - (if (length> e 3) - (begin (deprecation-message (string "The form `Expr(:let, ex, binds...)` is deprecated. " - "Use `Expr(:let, Expr(:block, binds...), ex)` instead." #\newline) #f) - (return (expand-let `(let (block ,@(cddr e)) ,(cadr e)))))) (let ((ex (caddr e)) (binds (let-binds e))) (expand-forms @@ -1559,10 +1527,6 @@ (if ,g ,g ,(loop (cdr tail))))))))))) -;; If true, this will warn on all `for` loop variables that overwrite outer variables. -;; If false, this will try to warn only for uses of the last value after the loop. -(define *warn-all-loop-vars* #f) - (define (expand-for lhss itrs body) (define (outer? x) (and (pair? x) (eq? (car x) 'outer))) (let ((copied-vars ;; variables not declared `outer` are copied in the innermost loop @@ -1585,10 +1549,8 @@ (lhs (if outer (cadar lhss) (car lhss))) (body `(block - ;; NOTE: enable this to force loop-local var - #;,@(map (lambda (v) `(local ,v)) (lhs-vars lhs)) ,@(if (not outer) - (map (lambda (v) `(warn-if-existing ,v)) (lhs-vars lhs)) + (map (lambda (v) `(local ,v)) (lhs-vars lhs)) '()) ,(lower-tuple-assignment (list lhs state) next) ,(nest (cdr lhss) (cdr itrs)))) @@ -1823,7 +1785,7 @@ (error (string "invalid " syntax-str " \"" (deparse el) "\"")))))))) (define (expand-forms e) - (if (or (atom? e) (memq (car e) '(quote inert top core globalref outerref line module toplevel ssavalue null meta using import importall export))) + (if (or (atom? e) (memq (car e) '(quote inert top core globalref outerref line module toplevel ssavalue null meta using import export))) e (let ((ex (get expand-table (car e) #f))) (if ex @@ -1839,10 +1801,6 @@ 'let expand-let 'macro expand-macro-def 'struct expand-struct-def - 'type - (lambda (e) - (syntax-deprecation ":type expression head" ":struct" #f) - (expand-struct-def e)) 'try expand-try 'lambda @@ -1861,11 +1819,6 @@ (cons 'block (map expand-forms (cdr e)))))) - 'body - (lambda (e) - (syntax-deprecation ":body expression head" ":block" #f) - (expand-forms (cons 'block (cdr e)))) - '|.| (lambda (e) ; e = (|.| f x) (expand-fuse-broadcast '() e)) @@ -2043,10 +1996,6 @@ (receive (name params super) (analyze-type-sig sig) (abstract-type-def-expr name params super))))) - 'bitstype - (lambda (e) - (syntax-deprecation "Expr(:bitstype, nbits, name)" "Expr(:primitive, name, nbits)" #f) - (expand-forms `(primitive ,(caddr e) ,(cadr e)))) 'primitive (lambda (e) (let ((sig (cadr e)) @@ -2305,13 +2254,6 @@ `(call (top typed_vcat) ,t ,@a))))) '|'| (lambda (e) (expand-forms `(call (top adjoint) ,(cadr e)))) - '|.'| (lambda (e) (begin (deprecation-message (string "The postfix .' syntax is deprecated. " - "For vector v in v.', use transpose(v) " - "instead. For matrix A in A.', use " - "copy(transpose(A)) instead, unless A.' " - "appears as an argument of *, / or \\. In " - "those cases, use transpose(A) instead. " #\newline) #f) - (return (expand-forms `(call transpose ,(cadr e)))))) 'generator (lambda (e) @@ -2381,11 +2323,7 @@ (inbounds pop) (= ,idx (call (top add_int) ,idx 1))) `(for (= ,(cadr (car itrs)) ,(car iv)) - (block - ;; TODO: remove when all loop vars are local in 1.0 - ,.(map (lambda (v) `(local ,v)) - (lhs-vars (cadr (car itrs)))) - ,(construct-loops (cdr itrs) (cdr iv)))))) + ,(construct-loops (cdr itrs) (cdr iv))))) (let ((overall-itr (if (length= itrs 1) (car iv) prod))) `(scope-block @@ -2475,15 +2413,10 @@ (define (find-local-def-decls e) (find-decls 'local-def e)) (define (find-global-decls e) (find-decls 'global e)) -(define (implicit-locals e env deprecated-env glob) +(define (implicit-locals e env glob) ;; const decls on non-globals introduce locals (append! (diff (find-decls 'const e) glob) - (filter - (lambda (v) - (if (memq v deprecated-env) - (begin (syntax-deprecation (string "implicit assignment to global variable `" v "`") (string "global " v) #f) #f) - #t)) - (find-assigned-vars e env)))) + (find-assigned-vars e env))) (define (unbound-vars e bound tab) (cond ((or (eq? e 'true) (eq? e 'false) (eq? e UNUSED)) tab) @@ -2506,7 +2439,7 @@ ;; 3. variables assigned inside this scope-block that don't exist in outer ;; scopes ;; returns lambdas in the form (lambda (args...) (locals...) body) -(define (resolve-scopes- e env outerglobals implicitglobals lam renames newlam (sp '())) +(define (resolve-scopes- e env implicitglobals lam renames newlam (sp '())) (cond ((symbol? e) (let ((r (assq e renames))) (if r (cdr r) e))) ;; return the renaming for e, or e ((or (not (pair? e)) (quoted? e) (memq (car e) '(toplevel global symbolicgoto symboliclabel))) e) @@ -2518,17 +2451,12 @@ (if (not (memq (cadr e) env)) (error "no outer variable declaration exists for \"for outer\"")) '(null)) - ((eq? (car e) 'warn-if-existing) - (if (or (memq (cadr e) outerglobals) (memq (cadr e) implicitglobals)) - `(warn-loop-var ,(cadr e)) - '(null))) ((eq? (car e) 'lambda) (let* ((lv (lam:vars e)) (env (append lv env)) (body (resolve-scopes- (lam:body e) env ;; don't propagate implicit or outer globals '() - '() e ;; remove renames corresponding to local variables from the environment (filter (lambda (ren) (not (memq (car ren) lv))) @@ -2548,7 +2476,6 @@ ;; being declared global prevents a variable ;; assignment from introducing a local (append env glob iglo locals-declared vars-def) - outerglobals (append glob iglo))) (vars (delete-duplicates (append! locals-declared locals-implicit))) (all-vars (append vars vars-def)) @@ -2564,9 +2491,6 @@ vars)))) (need-rename (need-rename? vars)) (need-rename-def (need-rename? vars-def)) - (deprecated-loop-vars - (filter (lambda (v) (and (memq v env) (not (memq v locals-declared)))) - (delete-duplicates (find-decls 'warn-if-existing blok)))) ;; new gensym names for conflicting variables (renamed (map named-gensy need-rename)) (renamed-def (map named-gensy need-rename-def)) @@ -2585,8 +2509,7 @@ (memq var implicitglobals) ;; remove anything only added implicitly in the last scope block (memq var glob))))) ;; remove anything that's now global renames))) - (new-oglo (append iglo outerglobals)) ;; list of all implicit-globals from outside blok - (body (resolve-scopes- blok new-env new-oglo new-iglo lam new-renames #f sp)) + (body (resolve-scopes- blok new-env new-iglo lam new-renames #f sp)) (real-new-vars (append (diff vars need-rename) renamed)) (real-new-vars-def (append (diff vars-def need-rename-def) renamed-def))) (for-each (lambda (v) @@ -2602,41 +2525,32 @@ (if lam ;; update in-place the list of local variables in lam (set-car! (cddr lam) (append real-new-vars real-new-vars-def (caddr lam)))) - (let* ((warnings (map (lambda (v) `(warn-loop-var ,v)) deprecated-loop-vars)) - (body (if *warn-all-loop-vars* - body - (if (and (pair? body) (eq? (car body) 'block)) - (append body warnings) - `(block ,body ,@warnings))))) - (insert-after-meta ;; return the new, expanded scope-block - (blockify body) - (append! (map (lambda (v) `(local ,v)) real-new-vars) - (map (lambda (v) `(local-def ,v)) real-new-vars-def) - (if *warn-all-loop-vars* - (map (lambda (v) `(warn-loop-var ,v)) deprecated-loop-vars) - '())))))) + (insert-after-meta ;; return the new, expanded scope-block + (blockify body) + (append! (map (lambda (v) `(local ,v)) real-new-vars) + (map (lambda (v) `(local-def ,v)) real-new-vars-def))))) ((eq? (car e) 'module) (error "\"module\" expression not at top level")) ((eq? (car e) 'break-block) `(break-block ,(cadr e) ;; ignore type symbol of break-block expression - ,(resolve-scopes- (caddr e) env outerglobals implicitglobals lam renames #f sp))) ;; body of break-block expression + ,(resolve-scopes- (caddr e) env implicitglobals lam renames #f sp))) ;; body of break-block expression ((eq? (car e) 'with-static-parameters) `(with-static-parameters - ,(resolve-scopes- (cadr e) env outerglobals implicitglobals lam renames #f (cddr e)) + ,(resolve-scopes- (cadr e) env implicitglobals lam renames #f (cddr e)) ,@(cddr e))) ((and (eq? (car e) 'method) (length> e 2)) `(method - ,(resolve-scopes- (cadr e) env outerglobals implicitglobals lam renames #f) - ,(resolve-scopes- (caddr e) env outerglobals implicitglobals lam renames #f) - ,(resolve-scopes- (cadddr e) env outerglobals implicitglobals lam renames #f + ,(resolve-scopes- (cadr e) env implicitglobals lam renames #f) + ,(resolve-scopes- (caddr e) env implicitglobals lam renames #f) + ,(resolve-scopes- (cadddr e) env implicitglobals lam renames #f (append (method-expr-static-parameters e) sp)))) (else (cons (car e) (map (lambda (x) - (resolve-scopes- x env outerglobals implicitglobals lam renames #f sp)) + (resolve-scopes- x env implicitglobals lam renames #f sp)) (cdr e)))))) -(define (resolve-scopes e) (resolve-scopes- e '() '() '() #f '() #f)) +(define (resolve-scopes e) (resolve-scopes- e '() '() #f '() #f)) ;; pass 3: analyze variables @@ -2986,11 +2900,11 @@ f(x) = yt(x) (define lambda-opt-ignored-exprs (Set '(quote top core line inert local local-def unnecessary copyast - meta inbounds boundscheck simdloop decl warn-loop-var + meta inbounds boundscheck simdloop decl struct_type abstract_type primitive_type thunk with-static-parameters implicit-global global globalref outerref const-if-global const null ssavalue isdefined toplevel module lambda error - gc_preserve_begin gc_preserve_end import importall using export))) + gc_preserve_begin gc_preserve_end import using export))) (define (local-in? s lam) (or (assq s (car (lam:vinfo lam))) @@ -3094,7 +3008,7 @@ f(x) = yt(x) (del! unused (cadr e))) ;; in all other cases there's nothing to do except assert that ;; all expression heads have been handled. - #;(assert (memq (car e) '(= method new call foreigncall cfunction |::| &))))))) + #;(assert (memq (car e) '(= method new call foreigncall cfunction |::|))))))) (visit (lam:body lam)) ;; Finally, variables can be marked never-undef if they were set in the first block, ;; or are currently live, or are back in the unused set (because we've left the only @@ -3178,7 +3092,7 @@ f(x) = yt(x) ((atom? e) e) (else (case (car e) - ((quote top core globalref outerref line break inert module toplevel null meta warn-loop-var) e) + ((quote top core globalref outerref line break inert module toplevel null meta) e) ((=) (let ((var (cadr e)) (rhs (cl-convert (caddr e) fname lam namemap toplevel interp))) @@ -3479,8 +3393,7 @@ f(x) = yt(x) (first-line #t) (current-loc #f) (rett #f) - (deprecated-loop-vars (table)) - (deprecated-global-const-locs '()) + (global-const-error #f) (arg-map #f) ;; map arguments to new names if they are assigned (label-counter 0) ;; counter for generating label addresses (label-map (table)) ;; maps label names to generated addresses @@ -3582,7 +3495,7 @@ f(x) = yt(x) (not (simple-atom? arg)) (not (simple-atom? aval)) (not (and (pair? arg) - (memq (car arg) '(& quote inert top core globalref outerref boundscheck)))) + (memq (car arg) '(quote inert top core globalref outerref boundscheck)))) (not (and (symbol? aval) ;; function args are immutable and always assigned (memq aval (lam:args lam)))) (not (and (symbol? arg) @@ -3628,11 +3541,6 @@ f(x) = yt(x) (eq? (car e) 'globalref)) (underscore-symbol? (cadr e))))) (syntax-deprecation "underscores as an rvalue" "" current-loc)) - (if (and (not *warn-all-loop-vars*) (has? deprecated-loop-vars e)) - (begin (deprecation-message - (string "Use of final value of loop variable `" e "`" (linenode-string current-loc) " " - "is deprecated. In the future the variable will be local to the loop instead.") current-loc) - (del! deprecated-loop-vars e))) (cond (tail (emit-return e1)) (value e1) ((or (eq? e1 'true) (eq? e1 'false)) #f) @@ -3644,14 +3552,6 @@ f(x) = yt(x) ((call new foreigncall cfunction) (let* ((args (cond ((eq? (car e) 'foreigncall) - (for-each (lambda (a) - (if (and (length= a 2) (eq? (car a) '&)) - (deprecation-message - (string "Syntax `&argument`" (linenode-string current-loc) - " is deprecated. Remove the `&` and use a `Ref` argument " - "type instead.") - current-loc))) - (list-tail e 6)) ;; NOTE: 2nd to 5th arguments of ccall must be left in place ;; the 1st should be compiled if an atom. (append (if (or (atom? (cadr e)) @@ -3686,8 +3586,6 @@ f(x) = yt(x) (lhs (if (and arg-map (symbol? lhs)) (get arg-map lhs lhs) lhs))) - (if (and (not *warn-all-loop-vars*) (has? deprecated-loop-vars lhs)) - (del! deprecated-loop-vars lhs)) (if (and value rhs) (let ((rr (if (or (atom? rhs) (ssavalue? rhs) (eq? (car rhs) 'null)) rhs (make-ssavalue)))) @@ -3875,11 +3773,6 @@ f(x) = yt(x) (loop (cdr actions))))))) val))) - ((&) - (if (or (not value) tail) - (error "misplaced \"&\" expression")) - `(& ,(compile (cadr e) break-labels value tail))) - ((newvar) ;; avoid duplicate newvar nodes (if (and (not (and (pair? code) (equal? (car code) e))) @@ -3901,25 +3794,13 @@ f(x) = yt(x) ((implicit-global) #f) ((const) (if (local-in? (cadr e) lam) - (begin - (syntax-deprecation "`const` declaration on local variable" "" current-loc) - '(null)) + (error (string "unsupported `const` declaration on local variable" (format-loc current-loc))) (if (pair? (cadr lam)) - ;; delay these deprecation warnings to allow "misplaced struct" errors to happen first - (set! deprecated-global-const-locs - (cons current-loc deprecated-global-const-locs)) + ;; delay this error to allow "misplaced struct" errors to happen first + (if (not global-const-error) + (set! global-const-error current-loc)) (emit e)))) ((isdefined) (if tail (emit-return e) e)) - ((warn-loop-var) - (if (or *warn-all-loop-vars* - (not (local-in? (cadr e) lam))) - (deprecation-message - (string "Loop variable `" (cadr e) "`" (linenode-string current-loc) " " - "overwrites a variable in an enclosing scope. " - "In the future the variable will be local to the loop instead.") - current-loc) - (put! deprecated-loop-vars (cadr e) #t)) - '(null)) ((boundscheck) (if tail (emit-return e) e)) ((method) @@ -3979,7 +3860,7 @@ f(x) = yt(x) '(null)) ;; other top level expressions - ((import importall using export) + ((import using export) (check-top-level e) (emit e) (let ((have-ret? (and (pair? code) (pair? (car code)) (eq? (caar code) 'return)))) @@ -4038,12 +3919,8 @@ f(x) = yt(x) (else (set-car! (cdr point) `(leave ,(- hl target-level)))))))) handler-goto-fixups) - (for-each (lambda (loc) - (deprecation-message - (string "`global const` declarations may no longer appear inside functions." #\newline - "Instead, use a non-constant global, or a global `const var = Ref{T}()`.") - loc)) - (reverse! deprecated-global-const-locs)) + (if global-const-error + (error (string "`global const` delcaration not allowed inside function" (format-loc global-const-error)))) (let* ((stmts (reverse! code)) (di (definitely-initialized-vars stmts vi)) (body (cons 'block (filter (lambda (e) diff --git a/src/julia.h b/src/julia.h index 98cbcf602f44d..c3e762d8c6945 100644 --- a/src/julia.h +++ b/src/julia.h @@ -520,7 +520,6 @@ extern JL_DLLEXPORT jl_datatype_t *jl_tvar_type JL_GLOBALLY_ROOTED; extern JL_DLLEXPORT jl_datatype_t *jl_any_type JL_GLOBALLY_ROOTED; extern JL_DLLEXPORT jl_unionall_t *jl_type_type JL_GLOBALLY_ROOTED; extern JL_DLLEXPORT jl_unionall_t *jl_typetype_type JL_GLOBALLY_ROOTED; -extern JL_DLLEXPORT jl_value_t *jl_ANY_flag JL_GLOBALLY_ROOTED; extern JL_DLLEXPORT jl_datatype_t *jl_typename_type JL_GLOBALLY_ROOTED; extern JL_DLLEXPORT jl_typename_t *jl_type_typename JL_GLOBALLY_ROOTED; extern JL_DLLEXPORT jl_datatype_t *jl_sym_type JL_GLOBALLY_ROOTED; @@ -1342,7 +1341,6 @@ JL_DLLEXPORT void jl_module_using(jl_module_t *to, jl_module_t *from); JL_DLLEXPORT void jl_module_use(jl_module_t *to, jl_module_t *from, jl_sym_t *s); JL_DLLEXPORT void jl_module_import(jl_module_t *to, jl_module_t *from, jl_sym_t *s); -JL_DLLEXPORT void jl_module_importall(jl_module_t *to, jl_module_t *from); JL_DLLEXPORT void jl_module_export(jl_module_t *from, jl_sym_t *s); JL_DLLEXPORT int jl_is_imported(jl_module_t *m, jl_sym_t *s); JL_DLLEXPORT int jl_module_exports_p(jl_module_t *m, jl_sym_t *var); diff --git a/src/julia_internal.h b/src/julia_internal.h index 292c7d83547b5..7add0a3bda155 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -940,8 +940,7 @@ extern jl_sym_t *call_sym; extern jl_sym_t *invoke_sym; extern jl_sym_t *empty_sym; extern jl_sym_t *top_sym; extern jl_sym_t *module_sym; extern jl_sym_t *slot_sym; extern jl_sym_t *export_sym; extern jl_sym_t *import_sym; -extern jl_sym_t *importall_sym; extern jl_sym_t *toplevel_sym; -extern jl_sym_t *quote_sym; extern jl_sym_t *amp_sym; +extern jl_sym_t *toplevel_sym; extern jl_sym_t *quote_sym; extern jl_sym_t *line_sym; extern jl_sym_t *jl_incomplete_sym; extern jl_sym_t *goto_sym; extern jl_sym_t *goto_ifnot_sym; extern jl_sym_t *return_sym; extern jl_sym_t *unreachable_sym; diff --git a/src/macroexpand.scm b/src/macroexpand.scm index 83a3289ece00f..2c7a040e39f53 100644 --- a/src/macroexpand.scm +++ b/src/macroexpand.scm @@ -320,7 +320,7 @@ ,(resolve-expansion-vars-with-new-env (caddr arg) env m parent-scope inarg)))) (else `(global ,(resolve-expansion-vars-with-new-env arg env m parent-scope inarg)))))) - ((using import importall export meta line inbounds boundscheck simdloop gc_preserve gc_preserve_end) (map unescape e)) + ((using import export meta line inbounds boundscheck simdloop gc_preserve gc_preserve_end) (map unescape e)) ((macrocall) e) ; invalid syntax anyways, so just act like it's quoted. ((symboliclabel) e) ((symbolicgoto) e) diff --git a/src/method.c b/src/method.c index 485e66351129f..a1cb144e9ecb3 100644 --- a/src/method.c +++ b/src/method.c @@ -756,17 +756,6 @@ JL_DLLEXPORT void jl_method_def(jl_svec_t *argdata, JL_GC_PUSH3(&f, &m, &argtype); size_t i, na = jl_svec_len(atypes); int32_t nospec = 0; - for (i = 1; i < na; i++) { - jl_value_t *ti = jl_svecref(atypes, i); - if (ti == jl_ANY_flag || - (jl_is_vararg_type(ti) && jl_tparam0(jl_unwrap_unionall(ti)) == jl_ANY_flag)) { - jl_depwarn("`x::ANY` is deprecated, use `@nospecialize(x)` instead.", - (jl_value_t*)jl_symbol("ANY")); - if (i <= 32) - nospec |= (1 << (i - 1)); - jl_svecset(atypes, i, jl_substitute_var(ti, (jl_tvar_t*)jl_ANY_flag, (jl_value_t*)jl_any_type)); - } - } argtype = (jl_value_t*)jl_apply_tuple_type(atypes); for (i = jl_svec_len(tvars); i > 0; i--) { diff --git a/src/module.c b/src/module.c index 2afa015aace22..870a85a917640 100644 --- a/src/module.c +++ b/src/module.c @@ -391,18 +391,6 @@ JL_DLLEXPORT void jl_module_use(jl_module_t *to, jl_module_t *from, jl_sym_t *s) module_import_(to, from, s, 0); } -JL_DLLEXPORT void jl_module_importall(jl_module_t *to, jl_module_t *from) -{ - void **table = from->bindings.table; - for(size_t i=1; i < from->bindings.size; i+=2) { - if (table[i] != HT_NOTFOUND) { - jl_binding_t *b = (jl_binding_t*)table[i]; - if (b->exportp && (b->owner==from || b->imported)) - jl_module_import(to, from, b->name); - } - } -} - JL_DLLEXPORT void jl_module_using(jl_module_t *to, jl_module_t *from) { if (to == from) diff --git a/src/staticdata.c b/src/staticdata.c index 4465e5ef5c683..0f1aa9d1356ae 100644 --- a/src/staticdata.c +++ b/src/staticdata.c @@ -1641,7 +1641,7 @@ static void jl_init_serializer2(int for_serialize) jl_densearray_type, jl_void_type, jl_function_type, jl_typeofbottom_type, jl_unionall_type, jl_typename_type, jl_builtin_type, jl_code_info_type, jl_task_type, jl_uniontype_type, jl_typetype_type, jl_abstractstring_type, - jl_ANY_flag, jl_array_any_type, jl_intrinsic_type, jl_abstractslot_type, + jl_array_any_type, jl_intrinsic_type, jl_abstractslot_type, jl_methtable_type, jl_typemap_level_type, jl_typemap_entry_type, jl_voidpointer_type, jl_newvarnode_type, jl_array_symbol_type, jl_anytuple_type, jl_tparam0(jl_anytuple_type), diff --git a/src/toplevel.c b/src/toplevel.c index 1ec16344652ba..454bf7ed7e57e 100644 --- a/src/toplevel.c +++ b/src/toplevel.c @@ -513,7 +513,6 @@ int jl_is_toplevel_only_expr(jl_value_t *e) { return jl_is_expr(e) && (((jl_expr_t*)e)->head == module_sym || - ((jl_expr_t*)e)->head == importall_sym || ((jl_expr_t*)e)->head == import_sym || ((jl_expr_t*)e)->head == using_sym || ((jl_expr_t*)e)->head == export_sym || @@ -620,31 +619,6 @@ jl_value_t *jl_toplevel_eval_flex(jl_module_t *m, jl_value_t *e, int fast, int e else if (ex->head == module_sym) { return jl_eval_module_expr(m, ex); } - else if (ex->head == importall_sym) { - jl_sym_t *name = NULL; - jl_depwarn("`importall` is deprecated, use `using` or individual `import` statements instead", - (jl_value_t*)jl_symbol("importall")); - jl_module_t *from = eval_import_from(m, ex, "importall"); - size_t i = 0; - if (from) { - i = 1; - ex = (jl_expr_t*)jl_exprarg(ex, 0); - } - for (; i < jl_expr_nargs(ex); i++) { - jl_value_t *a = jl_exprarg(ex, i); - if (jl_is_expr(a) && ((jl_expr_t*)a)->head == dot_sym) { - name = NULL; - jl_module_t *import = eval_import_path(m, from, ((jl_expr_t*)a)->args, &name, "importall"); - if (name != NULL) { - import = (jl_module_t*)jl_eval_global_var(import, name); - if (!jl_is_module(import)) - jl_errorf("invalid %s statement: name exists but does not refer to a module", jl_symbol_name(ex->head)); - } - jl_module_importall(m, import); - } - } - return jl_nothing; - } else if (ex->head == using_sym) { size_t last_age = ptls->world_age; ptls->world_age = jl_world_counter; diff --git a/stdlib/Profile/src/Profile.jl b/stdlib/Profile/src/Profile.jl index 920b02186d471..189265ff3a4c5 100644 --- a/stdlib/Profile/src/Profile.jl +++ b/stdlib/Profile/src/Profile.jl @@ -217,8 +217,7 @@ function flatten(data::Vector, lidict::LineInfoDict) end end newdata = UInt64[] - for ip in data - local ip::UInt64 + for ip::UInt64 in data if haskey(newmap, ip) append!(newdata, newmap[ip]) else diff --git a/stdlib/Random/src/generation.jl b/stdlib/Random/src/generation.jl index 3138be859d99e..7ec0c3930eb32 100644 --- a/stdlib/Random/src/generation.jl +++ b/stdlib/Random/src/generation.jl @@ -196,7 +196,7 @@ function SamplerRangeFast(r::AbstractUnitRange{T}, ::Type{U}) where {T,U} isempty(r) && throw(ArgumentError("range must be non-empty")) m = (last(r) - first(r)) % unsigned(T) % U # % unsigned(T) to not propagate sign bit bw = (sizeof(U) << 3 - leading_zeros(m)) % UInt # bit-width - mask = (1 % U << bw) - (1 % U) + mask = ((1 % U) << bw) - (1 % U) SamplerRangeFast{U,T}(first(r), bw, m, mask) end diff --git a/stdlib/Sockets/src/IPAddr.jl b/stdlib/Sockets/src/IPAddr.jl index f024b1f94e7f3..9a3f39ef196eb 100644 --- a/stdlib/Sockets/src/IPAddr.jl +++ b/stdlib/Sockets/src/IPAddr.jl @@ -104,7 +104,7 @@ function ipv6_field(ip::IPv6,i) if i < 0 || i > 7 throw(BoundsError()) end - UInt16(ip.host&(UInt128(0xFFFF)<<(i*16))>>(i*16)) + UInt16((ip.host&(UInt128(0xFFFF)<<(i*16))) >> (i*16)) end show(io::IO, ip::IPv6) = print(io,"ip\"",ip,"\"") diff --git a/test/ccall.jl b/test/ccall.jl index ec7caa1970f41..20e554fb787f2 100644 --- a/test/ccall.jl +++ b/test/ccall.jl @@ -1364,8 +1364,8 @@ end @test Expr(:error, "more types than arguments for ccall") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B,),))) @test Expr(:error, "more types than arguments for ccall") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B, C), ))) @test Expr(:error, "more types than arguments for ccall") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B..., C...), ))) -@test Expr(:error, "only the trailing ccall argument type should have '...'") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B..., C...), x))) -@test Expr(:error, "only the trailing ccall argument type should have '...'") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B..., C...), x, y, z))) +@test Expr(:error, "only the trailing ccall argument type should have \"...\"") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B..., C...), x))) +@test Expr(:error, "only the trailing ccall argument type should have \"...\"") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B..., C...), x, y, z))) @test Expr(:error, "more types than arguments for ccall") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B, C...), ))) # cfunction on non-function singleton diff --git a/test/deprecation_exec.jl b/test/deprecation_exec.jl index e1f747121cf02..b98580e3ef0cb 100644 --- a/test/deprecation_exec.jl +++ b/test/deprecation_exec.jl @@ -120,38 +120,9 @@ global_logger(prev_logger) # #19089 @test (@test_deprecated Meta.parse("1.+2")) == :(1 .+ 2) - # #16356 - @test (@test_deprecated Meta.parse("0xapi")) == :(0xa * pi) - - # #22523 #22712 - @test (@test_deprecated Meta.parse("a?b:c")) == :(a ? b : c) - @test (@test_deprecated Meta.parse("a ?b:c")) == :(a ? b : c) - @test (@test_deprecated Meta.parse("a ? b:c")) == :(a ? b : c) - @test (@test_deprecated Meta.parse("a ? b :c")) == :(a ? b : c) - @test (@test_deprecated Meta.parse("?")) == Symbol("?") - - # #13079 - @test (@test_deprecated Meta.parse("1<<2*3")) == :(1<<(2*3)) - - # ([#19157], [#20418]). - @test remove_linenums!(@test_deprecated Meta.parse("immutable A; end")) == - remove_linenums!(:(struct A; end)) - @test remove_linenums!(@test_deprecated Meta.parse("type A; end")) == - remove_linenums!(:(mutable struct A; end)) - - # #19987 - @test remove_linenums!(@test_deprecated Meta.parse("try ; catch f() ; end")) == - remove_linenums!(:(try ; catch; f() ; end)) - # #15524 # @test (@test_deprecated Meta.parse("for a=b f() end")) == :(for a=b; f() end) @test_broken length(Test.collect_test_logs(()->Meta.parse("for a=b f() end"))[1]) > 0 - - # #23076 - @test (@test_deprecated Meta.parse("[a,b;]")) == :([a;b]) - - # #24452 - @test (@test_deprecated Meta.parse("(a...)")) == :((a...,)) end @@ -159,55 +130,14 @@ end # #16295 @test_deprecated Meta.lower(@__MODULE__, :(A.(:+)(a,b) = 1)) - # #11310 - @test_deprecated r"parametric method syntax" Meta.lower(@__MODULE__, :(f{T}(x::T) = 1)) - # #17623 @test_deprecated r"Deprecated syntax `function .+(...)`" Meta.lower(@__MODULE__, :(function .+(a,b) ; end)) - # #21774 (more uniform let expressions) - @test_deprecated Meta.lower(@__MODULE__, Expr(:let, :a)) - @test_deprecated Meta.lower(@__MODULE__, Expr(:let, :a, :(a=1), :(b=1))) - - # #23157 (Expression heads for types renamed) - @test_deprecated Meta.lower(@__MODULE__, Expr(:type, true, :A, Expr(:block))) - @test_deprecated Meta.lower(@__MODULE__, Expr(:bitstype, 32, :A)) - # #15032 @test_deprecated Meta.lower(@__MODULE__, :(a.(b) = 1)) - # #5332 - @test_deprecated Meta.lower(@__MODULE__, :(a.')) - - # #19324 - @test_deprecated r"implicit assignment to global" eval( - :(module M19324 - x=1 - for i=1:10 - x += i - end - end)) - # #24221 @test_deprecated r"underscores as an rvalue" Meta.lower(@__MODULE__, :(a=_)) - - # #22314 - @test_deprecated r"Use of final value of loop variable `i`.*is deprecated. In the future the variable will be local to the loop instead." Meta.lower(@__MODULE__, :( - function f() - i=0 - for i=1:10 - end - i - end)) - @test_deprecated r"Loop variable `i` overwrites a variable in an enclosing scope" eval(:( - module M22314 - i=10 - for i=1:10 - end - end)) - - # #6080 - @test_deprecated r"Syntax `&argument`.*is deprecated" Meta.lower(@__MODULE__, :(ccall(:a, Cvoid, (Cint,), &x))) end module LogTest diff --git a/test/syntax.jl b/test/syntax.jl index b3e07b77d2dd6..fb2446d59fade 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -1084,7 +1084,7 @@ end @test_throws ParseError Meta.parse("@ time") # issue #7479 -@test Meta.lower(Main, Meta.parse("(true &&& false)")) == Expr(:error, "misplaced \"&\" expression") +@test Meta.lower(Main, Meta.parse("(true &&& false)")) == Expr(:error, "invalid syntax &false") # if an indexing expression becomes a cat expression, `end` is not special @test_throws ParseError Meta.parse("a[end end]") @@ -1584,3 +1584,52 @@ macro foo28244(sym) end @test (@macroexpand @foo28244(kw)) == Expr(:call, GlobalRef(@__MODULE__,:bar), Expr(:kw)) @test eval(:(@macroexpand @foo28244($(Symbol("let"))))) == Expr(:error, "malformed expression") + +# #16356 +@test_throws ParseError Meta.parse("0xapi") + +# #22523 #22712 +@test_throws ParseError Meta.parse("a?b:c") +@test_throws ParseError Meta.parse("a ?b:c") +@test_throws ParseError Meta.parse("a ? b:c") +@test_throws ParseError Meta.parse("a ? b :c") +@test_throws ParseError Meta.parse("?") + +# #13079 +@test Meta.parse("1<<2*3") == :((1<<2)*3) + +# #19987 +@test_throws ParseError Meta.parse("try ; catch f() ; end") + +# #23076 +@test :([1,2;]) == Expr(:vect, Expr(:parameters), 1, 2) + +# #24452 +@test Meta.parse("(a...)") == Expr(Symbol("..."), :a) + +# #19324 +@test_throws UndefVarError(:x) eval(:(module M19324 + x=1 + for i=1:10 + x += i + end + end)) + +# #22314 +function f22314() + i = 0 + for i = 1:10 + end + i +end +@test f22314() == 0 + +module M22314 +i = 0 +for i = 1:10 +end +end +@test M22314.i == 0 + +# #6080 +@test Meta.lower(@__MODULE__, :(ccall(:a, Cvoid, (Cint,), &x))) == Expr(:error, "invalid syntax &x")