Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

Undefined behavior when modifying NullableArray internals #44

Open
davidagold opened this issue Jul 22, 2015 · 0 comments
Open

Undefined behavior when modifying NullableArray internals #44

davidagold opened this issue Jul 22, 2015 · 0 comments

Comments

@davidagold
Copy link
Contributor

julia> X = NullableArray([1:10...]);

julia> splice!(X.isnull, 1)
false

julia> X
10-element NullableArrays.NullableArray{Int64,1}:
    Nullable(1)
    Nullable(2)
    Nullable(3)
    Nullable(4)
    Nullable(5)
    Nullable(6)
    Nullable(7)
    Nullable(8)
    Nullable(9)
 #undef        

julia> length(X)
10

julia> length(X.isnull)
9

Okay, that's undefined behavior. But I can imagine the following (or something like it) biting somebody trying to do something reasonable:

julia> A = [1:10...];

julia> X = NullableArray(A);

julia> splice!(A, 1)
1

julia> X
9-element NullableArrays.NullableArray{Int64,1}:
 Nullable(2) 
 Nullable(3) 
 Nullable(4) 
 Nullable(5) 
 Nullable(6) 
 Nullable(7) 
 Nullable(8) 
 Nullable(9) 
 Nullable(10)

julia> X.isnull
10-element Array{Bool,1}:
 false
 false
 false
 false
 false
 false
 false
 false
 false
 false

Thoughts? Really it shouldn't be unexpected since Julia passes by reference, but I'm wondering if there's anything we ought to do to make it more obvious that you might have broken something. Then again, the best (and maybe only feasible) thing to do may just be to include a caveat in the documentation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant