Skip to content

Commit

Permalink
remove most front-end deprecations
Browse files Browse the repository at this point in the history
also disable "local declared twice" error

This permits declaring a loop variable as local inside the loop,
which was used during 0.7 to get the new scope behavior.
  • Loading branch information
JeffBezanson authored and alyst committed Aug 9, 2018
1 parent eb95940 commit d7dcf32
Show file tree
Hide file tree
Showing 26 changed files with 171 additions and 506 deletions.
2 changes: 1 addition & 1 deletion base/boot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 0 additions & 16 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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"))
Expand Down
5 changes: 0 additions & 5 deletions base/essentials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions doc/src/manual/mathematical-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
5 changes: 1 addition & 4 deletions src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand Down
6 changes: 2 additions & 4 deletions src/ast.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -408,8 +408,6 @@
(pair? (caddr x))
(length> (caddr x) 1)
(eq? (cadr (caddr x)) 'Vararg)))))
(define (trans? x) (and (pair? x) (eq? (car x) '|.'|)))
(define (ctrans? x) (and (pair? x) (eq? (car x) '|'|)))
(define (linenum? x) (and (pair? x) (eq? (car x) 'line)))

(define (make-assignment l r) `(= ,l ,r))
Expand Down
9 changes: 0 additions & 9 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
9 changes: 1 addition & 8 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 0 additions & 1 deletion src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down
28 changes: 13 additions & 15 deletions src/jlfrontend.scm
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@

(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))))))

(define (expand-toplevel-expr e)
(cond ((or (atom? e) (toplevel-only-expr? e))
(if (underscore-symbol? e)
(syntax-deprecation "underscores as an rvalue" "" #f))
(error "all-underscore identifier used as rvalue"))
e)
(else
(let ((last *in-expand*))
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit d7dcf32

Please sign in to comment.