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

[BUG] .append() member procedure doesn't work if vector created implicitly #337

Open
jembrown opened this issue Mar 8, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@jembrown
Copy link
Member

jembrown commented Mar 8, 2023

Describe the bug
When a vector is created implicitly by assigning a value to its first position, the .append() member procedure doesn't work. However, it does work if the vector is created using v().

To Reproduce

# Case 1
> z[1] <- 1
> z
   [ 1 ]
> z.append(2)
> z
   [ 1 ]

# Case 2
> z <- v(1)
> z
   [ 1 ]
> z.append(2)
> z
   [ 1, 2 ]

Expected behavior
All member procedures should be available to all vectors, regardless of how they are created.

@jembrown jembrown added the bug Something isn't working label Mar 8, 2023
@jembrown jembrown changed the title .append() member procedure doesn't work if vector created implicitly[BUG] [BUG] .append() member procedure doesn't work if vector created implicitly Mar 8, 2023
@hoehna
Copy link
Member

hoehna commented Mar 9, 2023

The issue is that in the first case there doesn't actually exist the vector in memory, only the elements of the vector z[1]. When you call 'z' it creates a temporary vector, so you append to the temporary vector that then gets thrown away.

I see that this is confusing but I'm not super sure how easy that is to fix.

@jembrown
Copy link
Member Author

Ah, ok. I didn't realize that's how vectors were handled in the first case. Perhaps that's ok if (i) the .append() method doesn't appear when you call z.methods() and/or (ii) an error is displayed when trying to call .append() on a temporary vector?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants