Describe the bug

The last argument in a redis.call('sunion' makes it ignore one of the sets (or something)

To reproduce

# create 2 sets
SADD s1 a
SADD s1 b
SADD s1 c
SADD s2 c
SADD s2 d

# GOOD
SUNION s1 s2
1) "c"
2) "b"
3) "d"
4) "a"

# GOOD
SUNION s1 s2 "not_a_key"
1) "c"
2) "b"
3) "d"
4) "a"

# GOOD
EVAL "return redis.call('sunion', unpack(KEYS))" 2 s1 s2
1) "c"
2) "b"
3) "d"
4) "a"

# GOOD
EVAL "return redis.call('sunion', unpack(KEYS))" 3 s1 s2 "not_a_key"
1) "c"
2) "b"
3) "d"
4) "a"

# GOOD
EVAL "return redis.call('sunion', unpack(KEYS), 'not_a_key')" 2 s1 s2
1) "c"
2) "b"
3) "d"
4) "a"

# GOOD
EVAL "return redis.call('sunion', 'not_a_key', unpack(KEYS))" 2 s1 s2
1) "c"
2) "b"
3) "d"
4) "a"

#BAD
EVAL "return redis.call('sunion', unpack(KEYS), 'not_a_key')" 2 s1 s2
1) "c"
2) "b"
3) "a"

In the last example for some reason it ignores s2 in the sunion call.

Expected behavior

redis.call('sunion' Should return exactly the same, not dependent on order of values.

Additional information

Latest version of Redis

Comment From: grahamjenson

NM, found out what the issue is

Multivals are cut off at the first value when inserting them into another multival before its end.

From https://benaiah.me/posts/everything-you-didnt-want-to-know-about-lua-multivals/

Comment From: oranagra

@grahamjenson good that you found that. can you please edit the title and close the issue. maybe i'll help some some day...

Comment From: itamarhaber

@grahamjenson thanks for sharing that link - I picked up quite a lot from it.