Skip to content

Fix deprecations #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ The action of `Appl()` and `|>` is similar, but everything is passed as a
single argument (a list).

```julia
julia> type Node children end
julia> mutable struct Node children end

julia> parse_one("abc", Appl(Star(p"."), Node))
1-element Array{Any,1}:
Expand Down
2 changes: 1 addition & 1 deletion src/core/debug.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ end
# this does nothing except delegate and, by simply "being seen" during
# disparch above, toggle debug state.

@auto_hash_equals type Trace<:Delegate
@auto_hash_equals mutable struct Trace<:Delegate
name::Symbol
matcher::Matcher
Trace(matcher) = new(:Trace, matcher)
Expand Down
2 changes: 1 addition & 1 deletion src/core/matchers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ end

# when first called, create base state and make internal transition

execute{S,I}(k::Config{S,I}, m::Breadth, s::Clean, i::I) = execute(k, m, BreadthYield{I}(i, Entry{I}[Entry{I}(i, CLEAN, Any[])]), i)
execute(k::Config{S,I}, m::Breadth, s::Clean, i::I) where {S,I} = execute(k, m, BreadthYield{I}(i, Entry{I}[Entry{I}(i, CLEAN, Any[])]), i)

# yield the top state

Expand Down
2 changes: 1 addition & 1 deletion src/core/parsers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ end
# these assume that any config construct takes a single source argument
# plus optional keyword args

function make{S}(config, source::S, matcher; debug=false, kargs...)
function make(config, source::S, matcher; debug=false, kargs...) where S
I = typeof(start(source))
k = config{S,I}(source; debug=debug, kargs...)
(k, Channel(c -> producer(c, k, matcher; debug=debug)))
Expand Down
2 changes: 1 addition & 1 deletion src/core/print.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

always_print(::Matcher) = false

print_field{N}(m::Matcher, n::Type{Val{N}}) = "$(N)"
print_field(m::Matcher, n::Type{Val{N}}) where {N} = "$(N)"

print_matcher(m::Matcher) = print_matcher(m, Set{Matcher}())

Expand Down
4 changes: 2 additions & 2 deletions src/core/sugar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ Opt!(m::Matcher) = Alt!(m, Epsilon())


# repeat via [lo:hi] or [n]
endof{M<:Matcher}(m::M) = typemax(Int)
size{M<:Matcher}(m::M, n) = endof(m)
endof(m::M) where {M<:Matcher} = typemax(Int)
size(m::M, n) where {M<:Matcher} = endof(m)
getindex(m::Matcher, r::Int, s::Symbol...) = getindex(m, r:r; s...)
function getindex(m::Matcher, r::UnitRange, s::Symbol...)
greedy = true
Expand Down
4 changes: 2 additions & 2 deletions src/core/transforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# transform successes (Empty and Value)
# function must return a Value instance

@auto_hash_equals type Transform<:Delegate
@auto_hash_equals mutable struct Transform<:Delegate
name::Symbol
matcher::Matcher
f::Function
Expand All @@ -23,7 +23,7 @@ success(k::Config, m::Transform, s, t, i, r::Value) = Success(TransformState(t),

# as above, but function also takes iterator

@auto_hash_equals type ITransform<:Delegate
@auto_hash_equals mutable struct ITransform<:Delegate
name::Symbol
matcher::Matcher
f::Function
Expand Down
14 changes: 7 additions & 7 deletions src/core/try.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ end

# the Try() matcher that enables backtracking

@auto_hash_equals type Try<:Delegate
@auto_hash_equals mutable struct Try<:Delegate
name::Symbol
matcher::Matcher
Try(matcher) = new(:Try, matcher)
Expand All @@ -91,25 +91,25 @@ end

execute(k::Config, m::Try, s::Clean, i) = error("use Try only with TrySource")

execute{S<:TrySource}(k::Config{S}, m::Try, s::Clean, i) = execute(k, m, TryState(CLEAN), i)
execute(k::Config{S}, m::Try, s::Clean, i) where {S<:TrySource} = execute(k, m, TryState(CLEAN), i)

function execute{S<:TrySource}(k::Config{S}, m::Try, s::TryState, i)
function execute(k::Config{S}, m::Try, s::TryState, i) where S<:TrySource
k.source.frozen += 1
Execute(m, s, m.matcher, s.state, i)
end

function success{S<:TrySource}(k::Config{S}, m::Try, s::TryState, t, i, r::Value)
function success(k::Config{S}, m::Try, s::TryState, t, i, r::Value) where S<:TrySource
k.source.frozen -= 1
Success(TryState(t), i, r)
end

function failure{S<:TrySource}(k::Config{S}, m::Try, s::TryState)
function failure(k::Config{S}, m::Try, s::TryState) where S<:TrySource
k.source.frozen -= 1
FAILURE
end


function dispatch{S<:TrySource}(k::NoCache{S}, s::Success)
function dispatch(k::NoCache{S}, s::Success) where S<:TrySource
(parent, parent_state) = pop!(k.stack)
expire(k.source, s.iter)
try
Expand All @@ -119,7 +119,7 @@ function dispatch{S<:TrySource}(k::NoCache{S}, s::Success)
end
end

function dispatch{S<:TrySource}(k::Cache{S}, s::Success)
function dispatch(k::Cache{S}, s::Success) where S<:TrySource
parent, parent_state, key = pop!(k.stack)
expire(k.source, s.iter)
try
Expand Down
4 changes: 2 additions & 2 deletions src/core/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ abstract type Config{S,I} end

# defaults for mismatching types and types with no content
==(a::Matcher, b::Matcher) = false
=={T<:Matcher}(a::T, b::T) = true
==(a::T, b::T) where {T<:Matcher} = true
==(a::State, b::State) = false
=={T<:State}(a::T, b::T) = true
==(a::T, b::T) where {T<:State} = true


# use an array to handle empty values in a natural way
Expand Down
6 changes: 3 additions & 3 deletions test/bug/deadlock.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

using AutoHashEquals

@compat abstract type Graph end
abstract type Graph end

@auto_hash_equals type Node<:Graph
@auto_hash_equals mutable struct Node<:Graph
label::String
children::Vector{Graph}
Node(label, children...) = new(label, Graph[children...])
end

type Cycle<:Graph
mutable struct Cycle<:Graph
node::Nullable{Graph}
Cycle() = new(Nullable{Graph}())
end
Expand Down
4 changes: 2 additions & 2 deletions test/core/case.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ using AutoHashEquals

# every matcher has a name field, which by default is the name of the matcher
# (using @with_names changes this to the variable name - see calc.jl)
@auto_hash_equals type Case<:Delegate
@auto_hash_equals mutable struct Case<:Delegate
name::Symbol
matcher::Matcher
Case(matcher) = new(:Case, matcher)
end

immutable CaseState<:DelegateState
struct CaseState<:DelegateState
state::State
end

Expand Down
10 changes: 5 additions & 5 deletions test/core/fix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import Base: ==
signed_prod(lst) = length(lst) == 1 ? lst[1] : Base.prod(lst)
signed_sum(lst) = length(lst) == 1 ? lst[1] : Base.sum(lst)

@compat abstract type Node end
abstract type Node end
==(n1::Node, n2::Node) = isequal(n1.val, n2.val)
calc(n::Float64) = n
type Inv<:Node val end
mutable struct Inv<:Node val end
calc(i::Inv) = 1.0/calc(i.val)
type Prd<:Node val end
mutable struct Prd<:Node val end
calc(p::Prd) = signed_prod(map(calc, p.val))
type Neg<:Node val end
mutable struct Neg<:Node val end
calc(n::Neg) = -calc(n.val)
type Sum<:Node val end
mutable struct Sum<:Node val end
calc(s::Sum) = signed_sum(map(calc, s.val))

@with_names begin
Expand Down
4 changes: 2 additions & 2 deletions test/core/speed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ function run_type(n)
println("types: $count")
end

type A end
type B end
mutable struct A end
mutable struct B end

function random_type()
if rand(1:2) == 1
Expand Down
6 changes: 3 additions & 3 deletions test/core/stack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ stack(0, 10)
@time println(stack(0, 100_000))
# stack limit is somewhere around 100,000 (certainly less than 200,000)

@compat abstract type Msg end
abstract type Msg end

type Call<:Msg
mutable struct Call<:Msg
before::Function
after::Function
value::Int
end

type Return<:Msg
mutable struct Return<:Msg
value::Int
end

Expand Down
6 changes: 1 addition & 5 deletions test/gml/errors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ for (text, msg) in [("a 1 ]", "Expected key"),
end
end

if VERSION < v"0.5-"
@test_throws ParserError parse_raw(text)
else
@test_throws ParserError{Int64} parse_raw(text)
end
@test_throws ParserError{Int64} parse_raw(text)

end

Expand Down