Skip to content
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

Fix issue 19534 #19566

Merged
merged 1 commit into from
Jan 6, 2017
Merged

Fix issue 19534 #19566

merged 1 commit into from
Jan 6, 2017

Conversation

mauro3
Copy link
Contributor

@mauro3 mauro3 commented Dec 12, 2016

This fixes #19534.

@@ -1,22 +1,78 @@
# weak key dictionaries

type WeakKeyDict{K,V} <: Associative{K,V}
ht::Dict{Any,V}
ht::Dict{WeakRef,V}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is unrelated. I can revert it but it seems to me that the stricter type is a bit saver.

end
WeakKeyDict() = WeakKeyDict{Any,Any}()

WeakKeyDict(kv::Tuple{}) = WeakKeyDict()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These outer constructors are copies of the Dict ones. It could be DRYed up using something along the lines of

type A1{T}
    a::T
    A1(x) = new(x)
end
type A2{T}
    a::T
    A2(x) = new(x)
end
typealias A Union{A1,A2}
(::Type{TA}){TA<:A,T}(x::T) = TA{T}(x)

However, I suspect that there will be boot-strap isssues as WeakKeyDict comes later, thus these constructors would need to be added to weakkeydict.jl. Alternatively, I could put a comment into dict.jl to state to keep the constructors synchronized.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with the comment in dict.jl

@StefanKarpinski
Copy link
Sponsor Member

Could you make the commit message a bit more informative?

@mauro3
Copy link
Contributor Author

mauro3 commented Dec 13, 2016

@StefanKarpinski, yes will do. I'll also squash into one. (I'll wait for a bit for other comments)

@mauro3
Copy link
Contributor Author

mauro3 commented Dec 13, 2016

Fixed up commit message. Fixed Int64 issue in tests.

@@ -628,7 +639,10 @@ Dict(1 => rand(2,3), 'c' => "asdf") # just make sure this does not trigger a dep
@test !isempty(wkd)

wkd = empty!(wkd)
@test wkd==similar(wkd)
@test typeof(wkd)==typeof(similar(wkd))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces around == will be more readable. also no need for the blank line before end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unaddressed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to have wasted your time, I forgot to push...

@mauro3
Copy link
Contributor Author

mauro3 commented Dec 13, 2016

The Appveyor build got to Build success but seems to be stuck there for almost an hour. Any idea what that is?

@mauro3
Copy link
Contributor Author

mauro3 commented Dec 13, 2016

That appveyor build is stuck for sure.

- constructors for Pairs and iterables
- updated tests
- unrelated: changed wrapped dict to a tighter type
@mauro3
Copy link
Contributor Author

mauro3 commented Jan 3, 2017

Updated formatting of tests according to @tkelman's comment.

Copy link
Contributor

@tkelman tkelman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@tkelman
Copy link
Contributor

tkelman commented Jan 5, 2017

If no other opinions here I'll merge this and #19515 later today.

@tkelman tkelman merged commit 1ccfd76 into JuliaLang:master Jan 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WeakKeyDict has not the usual Associative constructors
3 participants