Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS0193: ConstraintSolver error #5580

Closed
CharlesTaylor7 opened this issue Sep 3, 2018 · 12 comments
Closed

FS0193: ConstraintSolver error #5580

CharlesTaylor7 opened this issue Sep 3, 2018 · 12 comments

Comments

@CharlesTaylor7
Copy link

CharlesTaylor7 commented Sep 3, 2018

I'm getting a compiler error message of:

error FS: internal error: Exception of type 'Microsoft.FSharp.Compiler.ConstraintSolver+LocallyAbortOperationThatFailsToResolveOverload' was thrown.

Reproduce steps

Minimal Example in Sharp Lab

Expected behavior

Compiler should report type constraint mismatch for the function test.

Actual behavior

Compiler exception when solving the constraint.

Known workarounds

Deleting either of the * overloads for Polynomial causes the compiler to display a sensible error. Replacing the float literals of 1.0 & 0.5 with decimal literals 1.0m & 0.5m fixes the compiler errors.

@cartermp
Copy link
Contributor

cartermp commented Sep 3, 2018

Further reduced repro:

type Complex = unit

type Polynomial () =
    static member (*) (s: decimal, p: Polynomial) : Polynomial = failwith ""
    static member (*) (s: Complex, p: Polynomial) : Polynomial = failwith ""

module Foo =
    let test t (p: Polynomial) = (1.0 - t) * p

Quick look shows that the error doesn't recover, so that's likely the bug.

@cartermp cartermp added this to the 16.0 milestone Sep 3, 2018
@cartermp
Copy link
Contributor

cartermp commented Sep 4, 2018

Leaking of this internal error is a regression.

F# 4.0: https://repl.it/@cartermp/GlisteningBoilingQuagga

@forki
Copy link
Contributor

forki commented Sep 4, 2018 via email

@TIHan
Copy link
Contributor

TIHan commented Sep 4, 2018

@forki it is not resolved with the recovery fix. I just tested it.

@TIHan TIHan self-assigned this Sep 4, 2018
@TIHan
Copy link
Contributor

TIHan commented Sep 4, 2018

I found the PR that caused this, and the exact changes: https://github.com/Microsoft/visualfsharp/pull/1650/files#diff-641da7c52ffc888699888ebd03559cb5R1285

I came across this by looking at all the history of changes in ConstraintSolver.fs.

Reverting lines 1285 - 1288 will fix this issue. I need to look at this more to see what it is doing.

@TIHan
Copy link
Contributor

TIHan commented Sep 4, 2018

Hmm. This seems more complex than I thought. Apparently that PR was reverted, #4173, but then was re-reverted, #4347 due to this: #4343

@TIHan
Copy link
Contributor

TIHan commented Sep 4, 2018

Quote from @dsyme regarding #1650

I'm not sure I understand. #1650 has been in for 18 months now and is now the "stable" state. I can see we need to remove the internal error showing above, but we need to do it in a way that doesn't change what does and doesn't compile.

It looks like we were aware of this internal error, but have no found a proper fix to resolve it. Reverting the PR causes other issues, so we have to figure out exactly what is going on to stop the internal error.

@jindraivanek
Copy link

Found another repro for this internal error.

FAKE5 script:

#r "paket: nuget Giraffe //"
open System.Threading.Tasks
open FSharp.Control.Tasks.ContextInsensitive

let foo t = task {
    let! t = t
    return t
    }

Error FS0071: Type constraint mismatch when applying the default type 'Task<'a>' for a type inference variable. internal error: Exception of type 'Microsoft.FSharp.Compiler.ConstraintSolver+LocallyAbortOperationThatFailsToResolveOverload' was thrown. Consider adding further type constraints

Annotating t with t: Task<'a> fix error.

@dsyme
Copy link
Contributor

dsyme commented Oct 25, 2018

Would be good to have a repro that wasn't a FAKE 5 script i.e. a normal F# project ZIP with exact version of Giraffe

thanks

@jindraivanek
Copy link

Here it is:
i5580.zip

@cartermp cartermp modified the milestones: 16.0, 16.1 Feb 21, 2019
@cartermp cartermp modified the milestones: 16.1, 16.2 Apr 23, 2019
@cartermp cartermp modified the milestones: 16.2, Backlog Apr 30, 2019
@cartermp
Copy link
Contributor

@dsyme this is resolved with #8294?

@cartermp
Copy link
Contributor

Just confirming that this emits a type constraint mismatch error now instead of the internal error
image

@cartermp cartermp modified the milestones: Backlog, .NET Core 3.1 Jun 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants