{"record":{"id":"073c5f7f0ae5cb0d","repo":"louthy/language-ext","slug":"notsupportedexception-seq","errorCode":null,"errorMessage":"NotSupportedException","messagePattern":"NotSupportedException","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"LanguageExt.Core/Immutable Collections/Seq/Seq.cs","lineNumber":386,"sourceCode":"                    // lhs concat, rhs empty\n                    // return lhs\n                    case SeqType.Empty:\n                        return this;\n\n                    // lhs concat, rhs lazy || lhs concat, rhs strict\n                    // add rhs to concat\n                    case SeqType.Lazy:\n                    case SeqType.Strict:\n                        return new Seq<A>(((SeqConcat<A>)value).AddSeq(rhs.value));\n\n                    // lhs concat, rhs concat\n                    // add rhs to concat\n                    case SeqType.Concat:\n                        return new Seq<A>(((SeqConcat<A>)value).AddSeqRange(((SeqConcat<A>)rhs.value).ms));\n                }\n                break;\n        }\n        throw new NotSupportedException();\n    }\n\n    /// <summary>\n    /// Prepend an item to the sequence\n    /// </summary>\n    [Pure]\n    [MethodImpl(MethodImplOptions.AggressiveInlining)]\n    internal Seq<A> Cons(A value) =>\n        new (Value.Cons(value));\n\n    /// <summary>\n    /// Head item in the sequence.\n    /// </summary>\n    /// <remarks>\n    /// If `IsEmpty` is `true` then Head is undefined and therefore returns `None`\n    /// </remarks>\n    public Option<A> Head\n    {","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/louthy/language-ext/blob/2f0e3628242889774d4141960a35671a0280051f/LanguageExt.Core/Immutable Collections/Seq/Seq.cs#L368-L404","documentation":"Seq.Concat throws NotSupportedException when the internal optimization to merge two concatenated sequence representations does not apply — specifically when neither side's underlying SeqType matches a case the switch handles (e.g. an unexpected underlying value type). It signals an unhandled internal sequence-type combination in the Concat fast-path.","triggerScenarios":"Calling seqA.Concat(seqB) where one operand's internal value is a SeqType not covered by the switch (not item-yield or concat types), or where the cast to SeqConcat<A> inside the Concat case is invalid for that combination.","commonSituations":"Mixing sequences created through different construction paths (lazily built vs. from arrays vs. previously concatenated) and hitting a code path not covered by the internal switch; usually indicates a library-level gap rather than caller misuse.","solutions":["Update LanguageExt — this is an internal optimization gap that may be fixed in newer versions","Work around by forcing a common representation before concatenating, e.g. seqA.ToSeq().Concat(seqB.ToSeq()) or building via Seq(a) literals","Avoid Concat on exotic internal states: use Append/Add in a loop or IEnumerable composition (items1.Concat(items2).ToSeq())","If reproducible, file a bug with the sequence construction steps"],"exampleFix":"// before\nvar all = hugeSeq.Concat(otherSeq); // NotSupportedException on internal type\n// after\nvar all = hugeSeq.ToEnumerable().Concat(otherSeq.ToEnumerable()).ToSeq();","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"Seq<A> all;\ntry { all = a.Concat(b); }\ncatch (NotSupportedException) { all = a.ToEnumerable().Concat(b.ToEnumerable()).ToSeq(); }","preventionTips":["Keep both operands built via the same construction path (e.g. both from ToSeq())","Pin/upgrade LanguageExt version where Concat bugs are fixed","Fall back to IEnumerable.Concat + ToSeq for exotic sequence states"],"tags":["csharp","languageext","seq","concat","notsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"2f0e3628242889774d4141960a35671a0280051f","analyzedAt":"2026-09-15T03:31:55.716Z","contentChangedAt":"2026-09-15T03:31:55.716Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}