Skip to content

Commit

Permalink
Merge pull request #21777 from JuliaLang/jb/deprecate_type_reswords
Browse files Browse the repository at this point in the history
turn on deprecation warnings for `type` and `immutable`
  • Loading branch information
JeffBezanson authored May 17, 2017
2 parents 623eab4 + 9a8adb5 commit 7d77244
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 11 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Compiler/Runtime improvements
Deprecated or removed
---------------------

* The keyword `immutable` is fully deprecated to `struct`, and
`type` is fully deprecated to `mutable struct` ([#19157], [#20418]).

* The method `srand(rng, filename, n=4)` has been deprecated ([#21359]).


Expand Down
4 changes: 2 additions & 2 deletions base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ fieldoffset(x::DataType, idx::Integer) = (@_pure_meta; ccall(:jl_get_field_offse
Determine the declared type of a field (specified by name or index) in a composite DataType `T`.
```jldoctest
julia> immutable Foo
julia> struct Foo
x::Int64
y::String
end
Expand All @@ -361,7 +361,7 @@ Get the index of a named field, throwing an error if the field does not exist (w
or returning 0 (when err==false).
```jldoctest
julia> immutable Foo
julia> struct Foo
x::Int64
y::String
end
Expand Down
2 changes: 1 addition & 1 deletion doc/src/manual/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ importall OtherLib

export MyType, foo

type MyType
struct MyType
x
end

Expand Down
2 changes: 1 addition & 1 deletion examples/queens.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# n-queens (nqueens) solver, for nsquaresx-by-nsquaresy board

immutable Queen
struct Queen
x::Int
y::Int
end
Expand Down
5 changes: 2 additions & 3 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1331,11 +1331,10 @@
(expect-end (take-lineendings s) "primitive type"))))))
;; deprecated type keywords
((type)
;; TODO fully deprecate post-0.6
;;(syntax-deprecation s "type" "mutable struct")
(syntax-deprecation s "type" "mutable struct") ;; retain in 0.7
(parse-struct-def s #t word))
((immutable)
;;(syntax-deprecation s "immutable" "struct")
(syntax-deprecation s "immutable" "struct") ;; retain in 0.7
(parse-struct-def s #f word))
((bitstype)
(let* ((nb (with-space-sensitive (parse-cond s)))
Expand Down
2 changes: 1 addition & 1 deletion test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4896,7 +4896,7 @@ foo21568()
@test f21568([0]) == 1

# issue #21719
type T21719{V}
mutable struct T21719{V}
f
tol::Float64
goal::V
Expand Down
2 changes: 1 addition & 1 deletion test/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ let e = code_typed(f21175, ())[1].first.code[1]::Expr
end

# issue #10207
type T10207{A, B}
mutable struct T10207{A, B}
a::A
b::B
end
Expand Down
2 changes: 1 addition & 1 deletion test/sparse/sparsevector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ end
@test issparse([sprand(10,.1); rand(10)])


type t20488 end
mutable struct t20488 end

@testset "similar" begin
x = sparsevec(rand(3) .+ 0.1)
Expand Down
2 changes: 1 addition & 1 deletion test/subtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ end

# issue #21613
abstract type A21613{S <: Tuple} end
immutable B21613{S <: Tuple, L} <: A21613{S}
struct B21613{S <: Tuple, L} <: A21613{S}
data::NTuple{L,Float64}
end
@testintersect(Tuple{Type{B21613{Tuple{L},L}} where L, Any},
Expand Down

0 comments on commit 7d77244

Please sign in to comment.