Skip to content

Seq.cast's non-generic IEnumerable implementation doesn't throw even when the cast is to the wrong type #650

@kbattocchi

Description

@kbattocchi

This throws

let strings = [1] |> Seq.cast<string>
for s in strings do ()

but this doesn't

let strings = [1] |> Seq.cast<string> :> System.Collections.IEnumerable
for s in strings do ()

This can lead to other confusing behavior:

let sum = [1] |> Seq.cast<string> |> Seq.cast<int> |> Seq.sum // doesn't throw!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions