The : operator has some behavioural issues when used on arrays inside of a terniary statement.
Numbered Steps to Reproduce Problem:
Attempt to compile the code provided below, which will result in a failure
Code Snippet (if applicable) to Reproduce Problem:
/datum
var/four = 4
var/five = 5
/proc/main()
var/list/d = list()
d += new /datum()
return 4 == 5 ? d[1]:four : d[1]:five
Expected Results:
Compilation success
Actual Results:
Compilation failure
Does the problem occur:
Every time? Or how often? Every time
In other games? Compilation issue
In other user accounts? Compilation issue
On other computers? Compilation issue
When does the problem NOT occur?
When not using a terniary statement:
/datum
var/four = 4
var/five = 5
/proc/main()
var/list/d = list()
d += new /datum()
return d[1]:four
When not using an array (Gives output you would expect):
/datum
var/four = 4
var/five = 5
/proc/main()
var/d = new /datum()
return 4 == 5 ? d:four : d:five
When using ?:
/datum
var/four = 4
var/five = 5
/proc/main()
var/list/d = list()
d += new /datum()
return 4 == 5 ? d[1]?:four : d[1]?:five
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
Tested on 514, also fails
Workarounds:
The ?: operator works correctly, and the following code will compile:
/datum
var/four = 4
var/five = 5
/proc/main()
var/list/d = list()
d += new /datum()
return 4 == 5 ? d[1]?:four : d[1]?:five
This code still fails to compile.