SequenceFunctions::includingAt replaces the item at index instead of inserting values before it
-
Key: KERML11-218
-
Status: open
-
Source: private ( Mattis Espedal Hohmann)
-
Summary:
Library and versions
KerML Kernel Function Library, SequenceFunctions, file sysml.library/Kernel Libraries/Kernel Function Library/SequenceFunctions.kerml, lines 57 to 61. The text is identical at SysML-v2-Release tags 2026-07 and 2026-09 (commit b7a6b770) and at master (9546486f), checked 2026-11-03. Not checked against the machine-readable library of the published specification.
function includingAt{ in seq: Anything[0..*] ordered nonunique; in values: Anything[0..*] ordered nonunique; in index: Positive[1]; return : Anything[0..*] ordered nonunique = (seq->subsequence(1, index - 1), values, seq->subsequence(index + 1)); }Problem
The result keeps seq elements 1 to index−1, then values, then seq elements from index+1. The element seq#(index) is in none of the three parts, so it is dropped. The function replaces the item at index instead of inserting values at it.
The library uses the function as an insertion. The behavior addAt (same file, lines 91 to 97) is declared next to add and removeAt and binds seq to seq->includingAt(values, index). Its sibling excludingAt uses endIndex + 1 for its tail, which is the correct shift for a removal. The same shift is wrong for an insertion.
The library file has no doc comment on includingAt, so the intended meaning is taken from its name, from addAt and from excludingAt. We did not find a normative description of it in the specification text.
Expected and actual result
By reading the expression (not run):
- (10, 20, 30)->includingAt(99, 2) gives (10, 99, 30). An insertion gives (10, 99, 20, 30).
- The result has the same length as seq, and 20 is lost.
- Only index = size(seq) + 1 gives the expected result, because the tail is then empty anyway.
Proposed resolution
return : Anything[0..*] ordered nonunique = (seq->subsequence(1, index - 1), values, seq->subsequence(index));This keeps the other two parts unchanged and keeps the tail empty when index = size(seq) + 1.
-
Reported: KerML 1.0 — Tue, 3 Nov 2026 09:46 GMT
-
Updated: Wed, 4 Nov 2026 20:37 GMT