It seems to me that the issue, if any, is creating new entries in a
table, not assigning nils.
Yes.
When nil is assigned to a non-existing key, a table rehash may be triggered as if a new element was inserted.
This behaviour is obviously wrong.
Table rehashing is a very expensive operation, so it's worth adding a check on nil here.
Correct behaviour:
Nothing should be done if nil is assigned to a non-existing key.