Operations directly on the length of the list cannot exceed a length of 65535. What magic BYOND is doing on the back-end to make this happen I can't say (and really it's not interesting enough for me to investigate), but I'll make a small demonstration:
Numbered Steps to Reproduce Problem:
Change L.len directly to a number above 65535, or use ++L.len when list length is 65535 or higher.
Code Snippet (if applicable) to Reproduce Problem:
mob/verb/Test_1()
var/list/L = new(65536)
usr << "new/list(65536); result: [L.len]"
L.len = 65536
usr << "L.len = 65536; result: [L.len]"
mob/verb/Test_2()
var/list/L = new(65535)
usr << "Initial len: [L.len]"
L += null // Adding like this goes beyond 65535
usr << "Add an element: [L.len]"
++L.len
usr << "Increment length: [L.len]"
mob/verb/Test_3()
var/list/L = new(65535)
usr << "Initial len: [L.len]"
L.Add(null) // Add() works properly as well
usr << "Add an element: [L.len]"
Expected Results:
list.len should change to the correct value regardless of how list length is modified.
Actual Results:
list.len is capped at 65535 when modified directly.
Workarounds:
Add items to the list instead of altering list.len in code.