When you declare a variable of type seq or string without an initializer, it is default-initialized to a nil (zero) value, which is NOT a valid value for a seq or a string.
This is done to minimise heap allocations, but the tutorial emphasises "most sequence operations cannot deal with nil" and thus recommends that "one should use empty sequences @[] rather than nil as the empty value". Likewise when describing strings.
Hence, I propose that the default initializer for variables be changed from "init-to-nil" to "init-to-empty". This would change the initializer value for seq from nil to @[]; and for string from nil to "". No other types in this table would be changed (other than the change in meaning for what "default(A)" means for tuples, object, etc.).
Immediately below that table, there is already the note: "The implicit initialization can be avoided for optimization reasons with the noinit pragma."
A corresponding nilinit pragma could be added to the language to revert to init-to-nil rather than init-to-empty behaviour. Alternatively, you could explicitly initialize your seq to nil:
var s: seq[int] = nil
This change to default initialization won't break any existing code, merely make it slightly less efficient until the declaration has been updated with a nil-assignment. In contrast, any bugs in existing or future code will now be safely initialized to valid (empty) states.
Further details:
Which addresses this common gotcha with very similar end results. And it's cheaper since the nil tests are faster than heap allocations.