The order of operations as it applies to logic operators and "in list" seems at best counter-intuitive. As a descriptive example, the line
if(1 in list(1) || 2 in list(2))
necessarily returns false in spite of both "in" clauses appearing correct.
Using named lists makes this problem clearer; see below
Code Snippet (if applicable) to Reproduce Problem:
var/list/L1 = list(1)
var/list/L2 = list(2)
var/list/L3 = list(L1,L2)
world << "L1: list(1); L2: list(2); L3: list(L1,L2)"
world << "1) 1 in L1: [1 in L1]"
world << "2) 2 in L2: [2 in L2]"
world << "3) 1 in L1 || 2 in L2: [1 in L1 || 2 in L2]"
world << "4) L1 || 2: [L1 || 2]"
world << "5) L1 || 2 in L2: [L1 || 2 in L2]"
world << "6) L1 || 2 in L3: [L1 || 2 in L3]"
world << "7) L2 in L3 in L1: [L2 in L3 in L1]"
world << "8) 1 in L1 && 1: [1 in L1 && 1]"
It seems that the interpretation of line 3 (the original test case) is probably
1 in L1 || 2 in L2 equals
(1 in (L1 || 2)) in L2 equals
(1 in L1) in L2 equals
(0 or 1) in L2
Expected Results:
L1: list(1); L2: list(2); L3: list(L1,L2)
1) 1 in L1: 1
2) 2 in L2: 1
3) 1 in L1 || 2 in L2: 1
4) L1 || 2: L1 // proper shortcut returns value of first non-false parameter
5) L1 || 2 in L2: L1 // shortcut removes test operator
6) L1 || 2 in L3: L1 // shortcut removes test operator
7) L2 in L3 in L1: 1 // becomes (1 in L1), since 1 is used as 'true'
8) 1 in L1 && 1: 1 // test operator evaluates before logical operator
Actual Results:
L1: list(1); L2: list(2); L3: list(L1,L2)
1) 1 in L1: 1
2) 2 in L2: 1
3) 1 in L1 || 2 in L2: 0 // nominal test case
4) L1 || 2: L1 // correct, outputs /list
5) L1 || 2 in L2: 0 // return value of || taken as left hand input to test operator
6) L1 || 2 in L3: 1 // proof of line 5 comment
7) L2 in L3 in L1: 1 // correct
8) 1 in L1 && 1: 0 // return value of && taken as right hand input to test operator
Does the problem occur:
Yes, it does.
Workarounds:
Proper parenthesis.
// L2 = list(2)
9) 1 || 2 in L2: Expected 1, got 0 (1 in L2)
10) 0 || 2 in L2: Expected 1, got 1 (2 in L2)
var/list/L4 = list(2,0)
11) 0 && 2 in L4: Expected 0, got 1 (0 in L4)
12) 1 && 2 in L4: Expected 1, got 1 (2 in L4)
13) null && 2 in L4: Expected 0, got 0 (null in L4)