Bug in pushing with tuples
See original GitHub issueThere is a bug when we work with multidimensional arrays. When we push an array to an empty array, we get not an array of a 1 length containing the pushed array, but the original pushed array.
This makes things like #677 very hard to do, 'cause we need to make the first contatenation by hand using $foo = $foo, $bar
for the second push
in a situation like this:
$array = ()
for $i in 1..3
push($array, ($i $i))
.foo
val: unquote(join(', ', $array))
The code above gives us val: 1, 1, 2 2,3 3;
while we’d expect it to give us 1 1, 2 2, 3 3
.
The only fix I found is to do so:
$array = ()
for $i, $index in 1..3
$new = ($i $i)
if $index == 1
$array = $array, $new
else
push($array, $new)
.foo
val: unquote(join(', ', $array))
So, this is obviously a bug. However, fixing it could bring troubles if someone had used this incorrect behaviour in his code.
Issue Analytics
- State:
- Created 10 years ago
- Comments:5
Top Results From Across the Web
Pushing on array of tuple crashes Julia #33727 - GitHub
On Julia 1.1 1.2 1.3 function mean_foo(m) where {T} f = NTuple[] n = [1,1] for i in 1:2 x = ntuple(_->zeros(10),n[i]) for...
Read more >python - Tuples: += operator throws exception, but succeeds?
The assigning of t[0] to the top of the stack occurs with STORE_SUBSCR , which fails here as t itself is an immutable...
Read more >BUG #16846: "retrieved too many tuples in a bounded sort"
In this function, after reading the last tuple and judging that it does not belong to the previous group, the program breaks from...
Read more >Prefer List of Tuples over Tuple of Lists - Justin Austin
Using a list of tuples instead of a tuple of lists is an easy way to help make illegal states unrepresentable without any...
Read more >lost-tuple bug and fix for Rinda::TupleSpaceProxy.take
Pushing to the port fails if the process that called #take has exited, so the tuple will not be deleted from the tuplespace...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So the only workaround that I can come up with with the fix applied is doing the following.
This produces
Maybe someone else might find this useful.
Sorry me again, but since working on a project that uses the push bif frequently I’ve come across some issues with the proposed fix. It’s difficult to explain so I’ll try to demonstrate it with an example.
With the fix it doubles up the parentheses which causes issues when iterating through the list, as you have to iterate through two layers, rather than one.
With the fix produces
Without the fix this produces
I wish I could offer more help to contribute to a fix, but I’m not very familiar with the inner workings of Stylus.