question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New generic constraint error in 2.16.1

See original GitHub issue

I’m not sure what to do with this, so I figured reporting here and see if anyone knew would be my best course of action. We have a bot (renovate) that updates dependencies of projects at work, and the update from 2.16.0 to 2.16.1 of FsCheck broke our tests with the following error:

System.TypeLoadException : GenericArguments[0], 'b', on 'FsCheck.ReflectArbitrary+shrinkChildren@183-1[a]' violates the constraint of type parameter 'a'.
Stack Trace:
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at FsCheck.Runner.checkMethod(Config config, MethodInfo m, FSharpOption`1 target)
   at FsCheck.Check.Method(Config config, MethodInfo methodInfo, FSharpOption`1 target)
   at <StartupCode$FsCheck-Xunit>.$PropertyAttribute.testExec@199(PropertyTestCase this, IMessageBus messageBus, Object[] constructorArguments, CancellationTokenSource cancellationTokenSource, XunitTest test, RunSummary summary, TestOutputHelper outputHelper, Unit unitVar0)
----- Inner Stack Trace -----
   at FsCheck.ReflectArbitrary.reflectShrinkObj@226-7.Invoke(FSharpFunc`2 arg00)
   at Microsoft.FSharp.Core.FSharpFunc`2.InvokeFast[V,W,X](FSharpFunc`2 func, T arg1, TResult arg2, V arg3, W arg4)
   at FsCheck.ReflectArbitrary.reflectShrink[a,a](FSharpFunc`2 getShrink, a a)
   at FsCheck.Arb.Derive@1326.Shrinker(a a)
   at FsCheck.Testable.props@143-1[a,b,c](FSharpFunc`2 shrink, FSharpFunc`2 pf, a x)
   at FsCheck.Testable.shrinking[a,b,c](FSharpFunc`2 shrink, a x, FSharpFunc`2 pf)
   at FsCheck.Testable.forAll@163-1.Invoke(a _arg1)
   at FsCheck.GenBuilder.Bind@88.Invoke(Int32 n, StdGen r0)
   at FsCheck.Runner.test@96-1.GenerateNext(IEnumerable`1& next)
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl()
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.System-Collections-IEnumerator-MoveNext()
   at FsCheck.Common.loop@53-1.GenerateNext(IEnumerable`1& next)
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl()
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.System-Collections-IEnumerator-MoveNext()
   at FsCheck.Common.takeWhilePlusLast@61.GenerateNext(IEnumerable`1& next)
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.MoveNextImpl()
   at Microsoft.FSharp.Core.CompilerServices.GeneratedSequenceBase`1.System-Collections-IEnumerator-MoveNext()
   at Microsoft.FSharp.Collections.SeqModule.Fold[T,TState](FSharpFunc`2 folder, TState state, IEnumerable`1 source)
   at FsCheck.Runner.runner[a](Config config, a prop)
   at FsCheck.Runner.check[a](Config config, a p)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
kurtschelfthoutcommented, Aug 30, 2021

Fix released in 2.16.2

1reaction
kurtschelfthoutcommented, Aug 30, 2021

It’s strange, I can’t reproduce on master but I can reproduce with the build from NuGet. Thanks for the repro I’ll investigate further.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why isn't the new() generic constraint satisfied by a class ...
The following code fails to compile, producing a "Widget must be a non-abstract type with a public parameterless constructor" error. I would ...
Read more >
sdk/CHANGELOG.md at main · dart-lang/sdk
When code in a package uses a Dart SDK element annotated with @Since , analyzer will report a warning if the package's Dart...
Read more >
Constraints on type parameters - C# Programming Guide
Learn about constraints on type parameters. Constraints tell the compiler what capabilities a type argument must have.
Read more >
The pubspec file
SDK constraints. A package can indicate which versions of its dependencies it supports, but packages have another implicit dependency: the Dart platform itself....
Read more >
new constraint - C# Reference
The new constraint specifies that a type argument in a generic class or method declaration must have a public parameterless constructor.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found