: error FS0073: internal error: The lists had different lengths.list2 is 1 element shorter than list1Parameter name: list2 (ArgumentException)
FSC: error FS0193: internal error: The lists had different lengths.list2 is 1 element shorter than list1Parameter name: list2
FSC: error FS0073: internal error: The lists had different lengths.list2 is 1 element shorter than list1Parameter name: list2 (ArgumentException)
FSC: error FS0193: internal error: The lists had different lengths.list2 is 1 element shorter than list1Parameter name: list2
Happened as I changed a generic interface with a curried function (taking two functions) to using a tupled function (of two functions), where the generic type parameter is used in both function-parameters.
No internal errors from the compiler
Replace the tuple of two functions with a typed record.
Provide any related information
Unhandled Exception:
System.ArgumentException: The lists had different lengths.
list2 is 1 element shorter than list1
Parameter name: list2
at Microsoft.FSharp.Core.DetailedExceptions.invalidArgDifferentListLength[?] (System.String arg1, System.String arg2, System.Int32 diff) [0x00065] in <58f83c3fdff9fae1a74503833f3cf858>:0
at Microsoft.FSharp.Primitives.Basics.List.zip[T1,T2] (Microsoft.FSharp.Collections.FSharpList`1[T] xs1, Microsoft.FSharp.Collections.FSharpList`1[T] xs2) [0x00025] in <58f83c3fdff9fae1a74503833f3cf858>:0
at Microsoft.FSharp.Collections.ListModule.Zip[T1,T2] (Microsoft.FSharp.Collections.FSharpList`1[T] list1, Microsoft.FSharp.Collections.FSharpList`1[T] list2) [0x00001] in <58f83c3fdff9fae1a74503833f3cf858>:0
at Microsoft.FSharp.Compiler.Infos.GetInstantiationForMemberVal (Microsoft.FSharp.Compiler.TcGlobals+TcGlobals g, System.Boolean isCSharpExt, Microsoft.FSharp.Compiler.Tast+TType typ, Microsoft.FSharp.Compiler.Tast+ValRef vref, Microsoft.FSharp.Collections.FSharpList`1[T] minst) [0x00027] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.Infos+MethInfo.GetParamTypes (Microsoft.FSharp.Compiler.Import+ImportMap amap, Microsoft.FSharp.Compiler.Range+range m, Microsoft.FSharp.Collections.FSharpList`1[T] minst) [0x00074] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.TypeChecker.getDetails@6387 (Microsoft.FSharp.Compiler.TypeChecker+cenv cenv, Microsoft.FSharp.Compiler.Range+range mBinding, Microsoft.FSharp.Compiler.Infos+MethInfo absSlot) [0x0001b] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.TypeChecker.FreshenObjExprAbstractSlot[d,e] (Microsoft.FSharp.Compiler.TypeChecker+cenv cenv, Microsoft.FSharp.Compiler.TypeChecker+TcEnv env, Microsoft.FSharp.Compiler.Tast+TType implty, Microsoft.FSharp.Collections.FSharpList`1[T] virtNameAndArityPairs, Microsoft.FSharp.Compiler.TypeChecker+NormalizedBinding bind, Microsoft.FSharp.Collections.FSharpList`1[T] bindAttribs, System.String bindName, Microsoft.FSharp.Collections.FSharpList`1[T] absSlots) [0x0011f] in <58f83cd97f81fe20a7450383d93cf858>:0
at [email protected] (System.Tuple`4[T1,T2,T3,T4] tupledArg) [0x0001d] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Primitives.Basics.List.mapToFreshConsTail[a,b] (Microsoft.FSharp.Collections.FSharpList`1[T] cons, Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] f, Microsoft.FSharp.Collections.FSharpList`1[T] x) [0x00019] in <58f83c3fdff9fae1a74503833f3cf858>:0
at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] mapping, Microsoft.FSharp.Collections.FSharpList`1[T] x) [0x0004d] in <58f83c3fdff9fae1a74503833f3cf858>:0
at Microsoft.FSharp.Collections.ListModule.Map[T,TResult] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] mapping, Microsoft.FSharp.Collections.FSharpList`1[T] list) [0x00001] in <58f83c3fdff9fae1a74503833f3cf858>:0
at Microsoft.FSharp.Compiler.TypeChecker+ComputeObjectExprOverrides@6510.Invoke (Microsoft.FSharp.Compiler.TypeChecker+SyntacticUnscopedTyparEnv tpenv, System.Tuple`4[T1,T2,T3,T4] tupledArg) [0x000fc] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library+List.mapFold[a,b,c] (Microsoft.FSharp.Core.FSharpFunc`2[T,TResult] f, a s, Microsoft.FSharp.Collections.FSharpList`1[T] l) [0x00026] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.TypeChecker.ComputeObjectExprOverrides (Microsoft.FSharp.Compiler.TypeChecker+cenv cenv, Microsoft.FSharp.Compiler.TypeChecker+TcEnv env, Microsoft.FSharp.Compiler.TypeChecker+SyntacticUnscopedTyparEnv tpenv, Microsoft.FSharp.Collections.FSharpList`1[T] impls) [0x0003a] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.TypeChecker.TcObjectExpr (Microsoft.FSharp.Compiler.TypeChecker+cenv cenv, Microsoft.FSharp.Compiler.Tast+TType overallTy, Microsoft.FSharp.Compiler.TypeChecker+TcEnv env, Microsoft.FSharp.Compiler.TypeChecker+SyntacticUnscopedTyparEnv tpenv, Microsoft.FSharp.Compiler.Ast+SynType synObjTy, Microsoft.FSharp.Core.FSharpOption`1[T] argopt, Microsoft.FSharp.Collections.FSharpList`1[T] binds, Microsoft.FSharp.Collections.FSharpList`1[T] extraImpls, Microsoft.FSharp.Compiler.Range+range mNewExpr, Microsoft.FSharp.Compiler.Range+range mWholeExpr) [0x00536] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.TypeChecker.TcExprUndelayed (Microsoft.FSharp.Compiler.TypeChecker+cenv cenv, Microsoft.FSharp.Compiler.Tast+TType overallTy, Microsoft.FSharp.Compiler.TypeChecker+TcEnv env, Microsoft.FSharp.Compiler.TypeChecker+SyntacticUnscopedTyparEnv tpenv, Microsoft.FSharp.Compiler.Ast+SynExpr expr) [0x010b7] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.TypeChecker.TcExpr (Microsoft.FSharp.Compiler.TypeChecker+cenv cenv, Microsoft.FSharp.Compiler.Tast+TType ty, Microsoft.FSharp.Compiler.TypeChecker+TcEnv env, Microsoft.FSharp.Compiler.TypeChecker+SyntacticUnscopedTyparEnv tpenv, Microsoft.FSharp.Compiler.Ast+SynExpr expr) [0x00002] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x00087] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x00087] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x00087] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x00087] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x00087] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x00087] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x00087] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x00087] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ReraiseIfWatsonable (System.Exception exn) [0x00040] in <58f83cd97f81fe20a7450383d93cf858>:0
at Microsoft.FSharp.Compiler.ErrorLogger+ErrorLoggerExtensions.ErrorLogger.ErrorRecovery (Microsoft.FSharp.Compiler.ErrorLogger+ErrorLogger x, System.Exception exn, Microsoft.FSharp.Compiler.Range+range m) [0x00087] in <58f83cd97f81fe20a7450383d93cf858>:0
Could you provide a minimal code snippet on which this error reproduces?
Yes, we ideally need a repro of some kind for this, though the stack is enough to give a better error message
I can't provide a minimal repro off the bat since it involves nester interfaces with generic type parameters and type inferrence and generic type aliases, but I can probably find the error, fix it, and report on type signatures.
Sketch of the type hierarchy:
type Specialised<'state> =
abstract member bax: unit -> 'state
type Filler =
abstract member barfoo: unit -> int
type Parent =
abstract member bind: (('state -> Json<unit>) * Json<'state> -> Specialised<'state>
type Child =
inherit Parent
inherit Filler
abstract member foobar: int -> unit
module Impl =
let toInterface (privateStruct: Stateful) =
{ new Child with
member x.foobar i = ()
member x.barfoo () = 43
member x.bind (ser, deser) =
{ new Specialised<'state> with
member x.bax () = ... } }
Changing
abstract member bind: (('state -> Json<unit>) * Json<'state> -> Specialised<'state>
to
type Pair<'state> = { ser: 'state -> Json<unit>; deser: Json<'state> }
...
abstract member bind: Pair<'state> -> Specialised<'state>
Makes it compile.
Also:
type Json =
| Number of n:decimal
| String of s:string
| ...
... etc in Chiron
type JsonResult<'t> =
| Error of string
| Value of 't
type Json<'t> = Json -> JsonResult<'t> * Json
I got same error with this snippet:
open System
type Flatten = Flatten
with
static member ($) (Flatten, (a: 'a, b: 'b)) : 'x list =
List.concat [ Flatten.Flat a; Flatten.Flat b]
static member Flat(x: obj) : 'x list =
match x with
| :? Tuple<'a, 'b> as t -> Flatten $ (t.Item1, t.Item2)
| _ -> [x]
Output:
Flatten.fsx(9,17): warning FS0064: This construct causes code to be less generic than indicated by the type annotations. The type variable 'x has been constrained to be type 'obj'.
Flatten.fsx(6,19): error FS0073: internal error: The lists had different lengths.
list2 is 2 elements shorter than list1
Parameter name: list2 (ArgumentException)
error FS0193: internal error: The lists had different lengths.
list2 is 2 elements shorter than list1
Parameter name: list2
Unhandled Exception: System.ArgumentException: The lists had different lengths.
list2 is 2 elements shorter than list1
Parameter name: list2
at Microsoft.FSharp.Core.DetailedExceptions.invalidArgDifferentListLength[?](String arg1, String arg2, Int32 diff)
at Microsoft.FSharp.Primitives.Basics.List.zip[T1,T2](FSharpList`1 xs1, FSharpList`1 xs2)
at Microsoft.FSharp.Compiler.Infos.GetInstantiationForMemberVal(TcGlobals g, Boolean isCSharpExt, TType typ, ValRef vref, FSharpList`1 minst)
at Microsoft.FSharp.Compiler.Infos.MethInfo.GetParamTypes(ImportMap amap, range m, FSharpList`1 minst)
at Microsoft.FSharp.Compiler.ConstraintSolver.CodegenWitnessThatTypSupportsTraitConstraint$cont@2598(TcGlobals g, ImportMap amap, range m, TraitConstraintInfo traitInfo, FSharpList`1 argExprs, FSharpChoice`4 sln, Unit unitVar)
at Microsoft.FSharp.Compiler.ConstraintSolver.CodegenWitnessThatTypSupportsTraitConstraint@2572.Invoke(Boolean _res)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeTraitCall(cenv cenv, IncrementalOptimizationEnv env, TraitConstraintInfo traitInfo, FSharpList`1 args, range m)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeLambdas(FSharpOption`1 vspec, cenv cenv, IncrementalOptimizationEnv env, ValReprInfo topValInfo, Expr e, TType ety)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeLambdas(FSharpOption`1 vspec, cenv cenv, IncrementalOptimizationEnv env, ValReprInfo topValInfo, Expr e, TType ety)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeApplication(cenv cenv, IncrementalOptimizationEnv env, Expr f0, TType f0ty, FSharpList`1 tyargs, FSharpList`1 args, range m)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeDecisionTreeTarget(cenv cenv, IncrementalOptimizationEnv env, range _m, DecisionTreeTarget _arg3)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeLinearExpr(cenv cenv, IncrementalOptimizationEnv env, Expr expr, FSharpFunc`2 contf)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeLambdas(FSharpOption`1 vspec, cenv cenv, IncrementalOptimizationEnv env, ValReprInfo topValInfo, Expr e, TType ety)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeBinding(cenv cenv, Boolean isRec, IncrementalOptimizationEnv env, Binding _arg4)
at Microsoft.FSharp.Compiler.ErrorLogger.ErrorLoggerExtensions.ReraiseIfWatsonable(Exception exn)
at Microsoft.FSharp.Compiler.ErrorLogger.ErrorLoggerExtensions.ErrorLogger.ErrorRecovery(ErrorLogger x, Exception exn, range m)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeBinding(cenv cenv, Boolean isRec, IncrementalOptimizationEnv env, Binding _arg4)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeModuleBinding(cenv cenv, IncrementalOptimizationEnv env, FSharpList`1 bindInfosColl, ModuleOrNamespaceBinding x)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeModuleBindings@3156-1.Invoke(ModuleOrNamespaceBinding x)
at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.List.mapFold[a,b,c](FSharpFunc`2 f, a s, FSharpList`1 l)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeModuleBindings(cenv cenv, IncrementalOptimizationEnv env, FSharpList`1 bindInfosColl, FSharpList`1 xs)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeModuleDef(cenv cenv, IncrementalOptimizationEnv env, FSharpList`1 bindInfosColl, ModuleOrNamespaceExpr x)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeModuleDefs@3171-1.Invoke(ModuleOrNamespaceExpr x)
at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.List.mapFold[a,b,c](FSharpFunc`2 f, a s, FSharpList`1 l)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeModuleDefs(cenv cenv, IncrementalOptimizationEnv env, FSharpList`1 bindInfosColl, FSharpList`1 defs)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeModuleDef(cenv cenv, IncrementalOptimizationEnv env, FSharpList`1 bindInfosColl, ModuleOrNamespaceExpr x)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeModuleBinding(cenv cenv, IncrementalOptimizationEnv env, FSharpList`1 bindInfosColl, ModuleOrNamespaceBinding x)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeModuleBindings@3156-1.Invoke(ModuleOrNamespaceBinding x)
at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.List.mapFold[a,b,c](FSharpFunc`2 f, a s, FSharpList`1 l)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeModuleBindings(cenv cenv, IncrementalOptimizationEnv env, FSharpList`1 bindInfosColl, FSharpList`1 xs)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeModuleDef(cenv cenv, IncrementalOptimizationEnv env, FSharpList`1 bindInfosColl, ModuleOrNamespaceExpr x)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeModuleDefs@3171-1.Invoke(ModuleOrNamespaceExpr x)
at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.List.mapFold[a,b,c](FSharpFunc`2 f, a s, FSharpList`1 l)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeModuleDefs(cenv cenv, IncrementalOptimizationEnv env, FSharpList`1 bindInfosColl, FSharpList`1 defs)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeModuleDef(cenv cenv, IncrementalOptimizationEnv env, FSharpList`1 bindInfosColl, ModuleOrNamespaceExpr x)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeModuleDefs@3171-1.Invoke(ModuleOrNamespaceExpr x)
at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.List.mapFold[a,b,c](FSharpFunc`2 f, a s, FSharpList`1 l)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeModuleDefs(cenv cenv, IncrementalOptimizationEnv env, FSharpList`1 bindInfosColl, FSharpList`1 defs)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeModuleDef(cenv cenv, IncrementalOptimizationEnv env, FSharpList`1 bindInfosColl, ModuleOrNamespaceExpr x)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeModuleExpr(cenv cenv, IncrementalOptimizationEnv env, ModuleOrNamespaceExprWithSig x)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeImplFileInternal(cenv cenv, IncrementalOptimizationEnv env, Boolean isIncrementalFragment, SignatureHidingInfo hidden, TypedImplFile _arg5)
at Microsoft.FSharp.Compiler.Optimizer.OptimizeImplFile(OptimizationSettings settings, CcuThunk ccu, TcGlobals tcGlobals, FSharpFunc`2 tcVal, ImportMap importMap, IncrementalOptimizationEnv optEnv, Boolean isIncrementalFragment, Boolean emitTaicalls, SignatureHidingInfo hidden, TypedImplFile mimpls)
at Microsoft.FSharp.Compiler.CompileOptions.ApplyAllOptimizations@1244-1.Invoke(TypedImplFile implFile)
at Microsoft.FSharp.Compiler.AbstractIL.Internal.Library.List.mapFold[a,b,c](FSharpFunc`2 f, a s, FSharpList`1 l)
at Microsoft.FSharp.Compiler.CompileOptions.ApplyAllOptimizations(TcConfig tcConfig, TcGlobals tcGlobals, FSharpFunc`2 tcVal, String outfile, ImportMap importMap, Boolean isIncrementalFragment, IncrementalOptimizationEnv optEnv, CcuThunk ccu, FSharpList`1 implFiles)
at Microsoft.FSharp.Compiler.Driver.main2a[a,b,c,d,e,f](Args`1 _arg1)
at Microsoft.FSharp.Compiler.Driver.typecheckAndCompile(String[] argv, Resolver referenceResolver, Boolean bannerAlreadyPrinted, Exiter exiter, ErrorLoggerProvider loggerProvider)
at Microsoft.FSharp.Compiler.Driver.mainCompile(String[] argv, Resolver referenceResolver, Boolean bannerAlreadyPrinted, Exiter exiter)
at Microsoft.FSharp.Compiler.CommandLineMain.Driver.main(String[] argv)
at Microsoft.FSharp.Compiler.CommandLineMain.main(String[] argv)
at Microsoft.FSharp.Compiler.ErrorLogger.ErrorLoggerExtensions.ReraiseIfWatsonable(Exception exn)
at Microsoft.FSharp.Compiler.ErrorLogger.ErrorLoggerExtensions.ErrorLogger.ErrorRecovery(ErrorLogger x, Exception exn, range m)
at Microsoft.FSharp.Compiler.CommandLineMain.main(String[] argv)
Thanks for the repro, that's great
(Though now looking at the code I wonder if they are the same issue)
Note to self: On the second issue, one problem is that when we save the minst here we are not correctly adjusting it after generalization completes
| FSMeth(_,typ,vref,_) ->
FSMethSln(typ,vref,minst)
I think the first issue is a different problem since it doesn't involve member constraints AFAICS
@dsyme This bit me over the past couples of days during some refactoring and it's been really difficult to pin down. I've made a minimal reproduction for you, see the following F# script file:
```f#
type Evaluator<'t,'ret> = abstract member Eval : ('t -> 'u) -> 'u list -> 'ret
and 't Crate = abstract member Eval : Evaluator<'t,'ret> -> 'ret
module Bar =
let foo (x : 't Crate) =
x.Eval { new Evaluator<_,_> with
member __.Eval (x, y) = failwith ""
}
Error:
internal error: The lists had different lengths.
list2 is 1 element shorter than list1
Parameter name: list2 (ArgumentException)
```
Note that the Eval method on the anonymous object takes a single tupled argument (x, y) instead of two distinct arguments x y. Using the latter fixes the internal error.
@dsyme it's worth pointing out that the above error (if the file is large enough) crashes Visual Studio. I've been using these 'crate' types very liberally in the code that I'm working on, and refactoring (removing/adding parameters) has been impossible. I've had to use VS Code because otherwise Visual Studio is crashing left/right/center due to this compile error.
I know you're extremely busy, but if you get a chance to take a look at this (and produce a sane error message in the correct location!), I'd be really grateful. (Or if you could point me to where to look, I'm happy to!)
@saul OK, thanks
I have workaround for @saul sample:
https://github.com/jindraivanek/visualfsharp/commit/8452d98b1dd4f68a20c0976fdc156aa23c0dd8b3
This doesn't solve my sample, looks like it really is a different issue.
Thanks @jindraivanek - what compile error do you get on the code sample with your fixes?
@saul
C:\dev\fsharp\fsc-bug\sample3.fsx(7,20): error FS0768: The member 'Eval' does not accept the correct number of arguments. 2 argument(s) are expected, but 2 were given. The required signature is 'member Evaluator.Eval : ('t -> 'u) -> 'u list -> 'ret'.
C:\dev\fsharp\fsc-bug\sample3.fsx(7,23): error FS0017: The member 'Eval : 'a * 'b -> 'c' does not have the correct type to override the corresponding abstract method. The required signature is 'Eval<'u> : ('t -> 'u) -> 'u list -> 'a'.
C:\dev\fsharp\fsc-bug\sample3.fsx(7,23): error FS0367: The member 'Eval : 'a * 'b -> 'c' does not have the correct number of arguments. The required signature is 'Eval<'u> : ('t -> 'u) -> 'u list -> 'a'.
C:\dev\fsharp\fsc-bug\sample3.fsx(6,22): error FS0783: At least one override did not correctly implement its corresponding abstract member
OK, that particular problem is fixed here: https://github.com/Microsoft/visualfsharp/pull/3275/
Error messages are as above. They aren't great in the case of a curried/uncurried mismtach "2 given, 2 expected" etc.
@dsyme you need to get some sleep.