Potential Set equality regression
See original GitHub issueHello, I believe I may have a encountered a quite recent regression with Sets.
Repro steps
Create script:
#r "nuget: NUnit, 3.13.3"
open System.Collections.Generic
open NUnit.Framework
let a : int Set = set (HashSet(0))
Assert.AreEqual(Set.empty, a)
Expected behaviour
Running this with the 7.0.102
SDK works out fine.
No exception is thrown.
Actual behaviour
When I run this with my latest local compiler, I got:
dotnet C:\Users\nojaf\Projects\fsharp\artifacts\bin\fsi\Debug\net7.0\fsi.dll .\set-problem.fsx
NUnit.Framework.AssertionException: Expected is <Microsoft.FSharp.Collections.FSharpSet`1[System.IComparable]>, actual is <Microsoft.FSharp.Collections.FSharpSet`1[System.Int32]>
at NUnit.Framework.Assert.ReportFailure(String message)
at NUnit.Framework.Assert.ReportFailure(ConstraintResult result, String message, Object[] args)
at NUnit.Framework.Assert.That[TActual](TActual actual, IResolveConstraint expression, String message, Object[] args)
at NUnit.Framework.Assert.AreEqual(Object expected, Object actual)
at <StartupCode$FSI_0002>.$FSI_0002.main@() in C:\Users\nojaf\Projects\set-problem.fsx:line 7
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
Related information
@T-Gro maybe this is related to https://github.com/dotnet/fsharp/commit/a9c194aac6ef8951ad0526aad237207838a8351f but that is a wild guess at this point.
Provide any related information (optional):
- Operating system: Windows 11
- .NET Runtime kind: dotnet 7
- Editing Tools (e.g. Visual Studio Version, Visual Studio)
Issue Analytics
- State:
- Created 8 months ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Testing equality of coefficients from two different regressions
Using the correct statistical test for equality of regression ... The trick is to set up the two equations as a system of...
Read more >Linear Equality Restrictions in Regression and Loglinear ...
The procedure described in this article implements restrictions by transforming the original variables into a new set of variables. These satisfy the desired ......
Read more >10.1 - What if the Regression Equation Contains "Wrong" ...
If the regression model is overspecified, then the regression equation contains one or more redundant predictor variables. That is, part of the model...
Read more >Seemingly unrelated regressions
Each equation is a valid linear regression on its own and can be estimated separately, which is why the system is called seemingly...
Read more >Multicollinearity in Regression Analysis: Problems, ...
Multicollinearity is when independent variables in a regression model are correlated. I explore its problems, testing your model for it, and solutions.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Intuitively, I wouldn’t expect the code to compile, since
Set.empty: obj
cannot infer the type parameter. If it must compile, I would expect it to be unlikely to evaluate to true, and more likely to evaluate to false, since the type parameter is unlikely to evaluate to int.Edit: On testing this,
Set.empty: obj
does compile, which seems like a bug, and the type inside the obj isset<IComparable>
. Given that it compiles, the behaviour seems conditionally correct sinceset<IComparable>
is not identical toset<int>
.It would be nice to enable a warning when anything is inferred to be of type obj, or passed into a function as an obj. In the absence of this, we use a test that bans the string “Assert.AreEqual” in .fs files.
😭 I’ve been trying to fix https://github.com/dotnet/fsharp/pull/13298 on-and-off for ages and ages, but I couldn’t get the tests passing.