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

Union types #157

Merged
merged 3 commits into from
Oct 30, 2022
Merged

Union types #157

merged 3 commits into from
Oct 30, 2022

Conversation

FredericWantiez
Copy link
Member

@FredericWantiez FredericWantiez commented Oct 30, 2022

Not sure it's an issue but seems a bit weird to override the deepcopy_types from what the user provides.
On master this produces the wrong result because Ref and Array are not deepcopied anymore

using Libtask

struct DummyType end

function f(start::Int)
    t = [start]
    while true
        produce(t[1])
        t[1] = 1 + t[1]
    end
end

ttask = TapedTask(f, 0; deepcopy_types=DummyType)
println(consume(ttask)) # 0 Correct 

ttask2 = copy(ttask)
println(consume(ttask2)) # 1 Correct

println(consume(ttask)) # 2 Incorrect
println(consume(ttask2)) # 3 Incorrect

Maybe we can assume that Array and Ref would always be deepcopied unless explicitly overloaded in tape_deepcopy ?

test/tape_copy.jl Outdated Show resolved Hide resolved
@yebai
Copy link
Member

yebai commented Oct 30, 2022

I am happy with the proposed change.

Just to clarify, it is not possible to override the copying behaviour for Array and Ref without modifying the global variable BASE_COPY_TYPES? Is that intended?

@FredericWantiez
Copy link
Member Author

Yes, not sure it's the best way but I don't really see a case where we want shallow copied arrays, and we can alsways overload tape_deepcopy(x::Array) explicitly. Happy to change

@yebai yebai merged commit 5ec9f2b into master Oct 30, 2022
@yebai yebai deleted the fred/fix_union_type branch October 30, 2022 22:07
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.

2 participants