dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.94k stars 788 forks source link

internal error: multiple methods appear with identical argument types #17796

Closed 0101 closed 1 month ago

0101 commented 2 months ago

Please provide a succinct description of the issue.

Repro steps

Provide the steps required to reproduce the problem:

  1. Checkout lsp branch
  2. build.cmd -c Debug or just build FSharp.Compiler.LanguageServer project

Expected behavior

Build completes successfully

Actual behavior

We get

error FS0192 : internal error : multiple methods named AddSingleton appear with identical argument types in type Microsoft.Extensions.DependencyInjection.ServiceCollectionSer
viceExtensions [D:\code\fsharp\src\FSharp.Compiler.LanguageServer\FSharp.Compiler.LanguageServer.fsproj]

Related information

Here's the code that triggers the error: https://github.com/dotnet/fsharp/blob/c1486be9a7db235018a27e8c3219309a10895891/src/FSharp.Compiler.LanguageServer/FSharpLanguageServer.fs#L46-L59

vzarytovskii commented 2 months ago

It might be caused by https://github.com/dotnet/fsharp/pull/16168 as well

DedSec256 commented 2 months ago

Referenced Microsoft.Extensions.DependencyInjection.Abstractions contains two extension methods with the same name AddSingleton and parameters count, but different number of generics

public static IServiceCollection AddSingleton<TService>(this IServiceCollection services)
public static IServiceCollection AddSingleton<TService, TImplementation>(this IServiceCollection services)

I think issue localized in this change from https://github.com/dotnet/fsharp/pull/17597

{20B9EFCA-9D59-4A0F-BDB7-9D6D96988964}

which triggers additional call of resolveILMethodRefWithRescope, which doesn't take generics into account when searching for methods, and therefore returns an error.

I managed to build the FSharp.Compiler.LanguageServer project locally after the revert of https://github.com/dotnet/fsharp/pull/17597

T-Gro commented 2 months ago

This makes sense Alex @DedSec256 , thanks. I will adjust that change. Surprisingly, resolveILMethodRefWithRescope is not new a was already used at different places before.

rstm-sf commented 1 month ago

@T-Gro hello, could you tell how can check the fix? In RC2 I get something like this

T-Gro commented 1 month ago

Yes, RC2 has this error. It has been fixed for the shipping version of the product and is fixed in code. But RC2 has it.

Thorium commented 3 weeks ago

I'm having similar error after updating to latest VS2022 Prerelease v5, 9.0.100-rc.2.24474.11 In Prerelease 2.1 I didn't have this.

Edit: @xperiandri pointed out that having a global.json to hard-code a previous version does help.