Skip to content

Ambiguous call to Where method on Fin<A> type due to multiple extension methods #1496

@hhko

Description

@hhko

Description

When calling the Where method on a Fin<A> type, the compiler throws a CS0121 error due to an ambiguous call between two extension methods with the same signature.

Background

The Fin<A> type implements multiple interfaces:

  • IEnumerable<A> - enables System.Linq.Enumerable.Where extension method
  • MonoidK<Fin> - enables LanguageExt.MonoidKExtensions.Where extension method

This creates a conflict when trying to call Where directly on a Fin<A> instance.

Steps to Reproduce

  1. Create a new .NET project with LanguageExt.Core 5.0.0-beta-54
  2. Write the following code:
using LanguageExt;
using static LanguageExt.Prelude;

var fin = Fin<int>.Succ(2025);
var result = fin.Where(x => x > 20); // CS0121 error occurs here
  1. Compile the project

Expected Behavior

The code should compile successfully, allowing one of the Where methods to be called unambiguously.

Actual Behavior

Compiler error CS0121:


I would appreciate any feedback if my understanding of the Fin type is inaccurate or incomplete.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions