Skip to content

[SRTP] New syntax does not work on 7 RC2 #14097

@xperiandri

Description

@xperiandri

Repro steps

module DiagnosticHandlers =

    let inline private optionsToIResult< ^o when ^o : (member Validate: unit -> Result< ^o, ValidationErrors>)> (options: ^o) =
        match options.Validate() with
        | Ok options -> Results.Ok options
        | Error errors -> Results.ValidationProblem(errors |> toErrors)

    let configuration: HttpHandler =

        fun _ context ->
            let configuration = context.GetService<IConfiguration>()
            Results.MultiResult(seq {
                struct ("EventStore", Results.Ok(EventStore.reportConfiguration configuration))
                struct ("Postgres", Results.Ok(Postgres.reportConfiguration configuration))
                struct (EkataOptions.SectionName, context.RequestServices.GetRequiredService<IOptions<EkataOptions>>().Value |> optionsToIResult)
                struct (SambaOptions.SectionName, context.RequestServices.GetRequiredService<IOptions<SambaOptions>>().Value |> optionsToIResult)
                struct (StripeOptions.SectionName, context.RequestServices.GetRequiredService<IOptions<StripeOptions>>().Value |> optionsToIResult)
                struct (``ThemisDS Options``.SectionName, context.RequestServices.GetRequiredService<IOptions<``ThemisDS Options``>>().Value |> optionsToIResult)
            }) |> ofIResult context

Expected behavior

Compiles well

Actual behavior

1>  error FS0192 : internal error : destFunTy: not a function type
1>
1>  Unhandled Exception: System.Exception: destFunTy: not a function type
1>     at FSharp.Compiler.TypedTreeOps.destFunTy(TcGlobals g, TType ty) in D:\a\_work\1\s\src\Compiler\TypedTree\TypedTreeOps.fs:line 818
1>     at [email protected](Expr _arg6) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 4585
1>     at Microsoft.FSharp.Collections.ListModule.Fold[T,TState](FSharpFunc`2 folder, TState state, FSharpList`1 list) in D:\a\_work\1\s\src\FSharp.Core\list.fs:line 295
1>     at FSharp.Compiler.IlxGen.GenIndirectCall(cenv cenv, CodeGenBuffer cgbuf, IlxGenEnv eenv, TType funcTy, FSharpList`1 tyargs, FSharpList`1 curriedArgs, Range m, sequel sequel) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 4583
1>     at FSharp.Compiler.IlxGen.GenCurriedArgsAndIndirectCall(cenv cenv, CodeGenBuffer cgbuf, IlxGenEnv eenv, TType funcTy, FSharpList`1 tyargs, FSharpList`1 curriedArgs, Range m, sequel sequel) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 4566
1>     at FSharp.Compiler.IlxGen.CommitGetStorageSequel[e](cenv cenv, CodeGenBuffer cgbuf, IlxGenEnv eenv, Range m, TType ty, FSharpOption`1 localCloInfo, FSharpOption`1 storeSequel) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 9538
1>     at FSharp.Compiler.IlxGen.GenGetStorageAndSequel(cenv cenv, CodeGenBuffer cgbuf, IlxGenEnv eenv, Range m, TType ty, ILType ilTy, ValStorage storage, FSharpOption`1 storeSequel) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 9593
1>     at FSharp.Compiler.IlxGen.GenTraitCall(cenv cenv, CodeGenBuffer cgbuf, IlxGenEnv eenv, TraitConstraintInfo traitInfo, FSharpList`1 argExprs, Range m, Expr expr, sequel sequel) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 5447
1>     at [email protected](Unit unitVar0) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 2856
1>     at FSharp.Compiler.DiagnosticsLogger.StackGuard.Guard[T](FSharpFunc`2 f) in D:\a\_work\1\s\src\Compiler\Facilities\DiagnosticsLogger.fs:line 837
1>     at FSharp.Compiler.IlxGen.GenBindingRhs(cenv cenv, CodeGenBuffer cgbuf, IlxGenEnv eenv, Val vspec, Expr expr) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 9471
1>     at FSharp.Compiler.IlxGen.GenBindingAfterDebugPoint(cenv cenv, CodeGenBuffer cgbuf, IlxGenEnv eenv, Binding bind, Boolean isStateVar, FSharpOption`1 startMarkOpt) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 8526
1>     at FSharp.Compiler.IlxGen.GenLinearExpr(cenv cenv, CodeGenBuffer cgbuf, IlxGenEnv eenv, Expr expr, sequel sequel, Boolean preSteps, FSharpFunc`2 contf) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 3395
1>     at FSharp.Compiler.IlxGen.GenExprAux(cenv cenv, CodeGenBuffer cgbuf, IlxGenEnv eenv, Expr expr, sequel sequel) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 2961
1>     at [email protected](Unit unitVar0) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 2856
1>     at FSharp.Compiler.DiagnosticsLogger.StackGuard.Guard[T](FSharpFunc`2 f) in D:\a\_work\1\s\src\Compiler\Facilities\DiagnosticsLogger.fs:line 837
1>     at [email protected](CodeGenBuffer cgbuf, IlxGenEnv eenv) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 3102
1>     at FSharp.Compiler.IlxGen.CodeGenThen(cenv cenv, AssemblyBuilder mgbuf, FSharpList`1 entryPointInfo, String methodName, IlxGenEnv eenv, Int32 alreadyUsedArgs, FSharpOption`1 selfArgOpt, FSharpFunc`2 codeGenFunction, Range m) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 2743
1>     at FSharp.Compiler.IlxGen.CodeGenMethod(cenv cenv, AssemblyBuilder mgbuf, FSharpList`1 entryPointInfo, String methodName, IlxGenEnv eenv, Int32 alreadyUsedArgs, FSharpOption`1 selfArgOpt, FSharpFunc`2 codeGenFunction, Range m) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 2778
1>     at FSharp.Compiler.IlxGen.CodeGenMethodForExpr(cenv cenv, AssemblyBuilder mgbuf, FSharpList`1 entryPointInfo, String methodName, IlxGenEnv eenv, Int32 alreadyUsedArgs, FSharpOption`1 selfArgOpt, Expr expr0, sequel sequel0) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 3105
1>     at FSharp.Compiler.IlxGen.GenMethodForBinding(cenv cenv, AssemblyBuilder mgbuf, IlxGenEnv eenv, Val v, ILMethodSpec mspec, Boolean hasWitnessEntry, Boolean generateWitnessArgs, ILMemberAccess access, FSharpList`1 ctps, FSharpList`1 mtps, FSharpList`1 witnessInfos, FSharpList`1 curriedArgInfos, FSharpList`1 paramInfos, FSharpList`1 argTys, ArgReprInfo retInfo, ValReprInfo valReprInfo, FSharpOption`1 ctorThisValOpt, FSharpOption`1 baseValOpt, FSharpList`1 methLambdaTypars, FSharpList`1 methLambdaVars, Expr methLambdaBody, TType returnTy) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 9078
1>     at FSharp.Compiler.IlxGen.GenBindings(cenv cenv, CodeGenBuffer cgbuf, IlxGenEnv eenv, FSharpList`1 binds, FSharpOption`1 stateVarFlagsOpt) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 9434
1>     at FSharp.Compiler.IlxGen.GenModuleOrNamespaceContents(cenv cenv, CodeGenBuffer cgbuf, QualifiedNameOfFile qname, List`1 lazyInitInfo, IlxGenEnv eenv, ModuleOrNamespaceContents x) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 10021
1>     at [email protected](IlxGenEnv eenv, ModuleOrNamespaceContents x)
1>     at Microsoft.FSharp.Collections.ListModule.Fold[T,TState](FSharpFunc`2 folder, TState state, FSharpList`1 list) in D:\a\_work\1\s\src\FSharp.Core\list.fs:line 295
1>     at FSharp.Compiler.IlxGen.GenModuleBinding(cenv cenv, CodeGenBuffer cgbuf, QualifiedNameOfFile qname, List`1 lazyInitInfo, IlxGenEnv eenv, Range m, ModuleOrNamespaceBinding x) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 10080
1>     at FSharp.Compiler.IlxGen.GenModuleOrNamespaceContents(cenv cenv, CodeGenBuffer cgbuf, QualifiedNameOfFile qname, List`1 lazyInitInfo, IlxGenEnv eenv, ModuleOrNamespaceContents x) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 10014
1>     at [email protected](IlxGenEnv eenv, ModuleOrNamespaceContents x)
1>     at Microsoft.FSharp.Collections.ListModule.Fold[T,TState](FSharpFunc`2 folder, TState state, FSharpList`1 list) in D:\a\_work\1\s\src\FSharp.Core\list.fs:line 295
1>     at FSharp.Compiler.IlxGen.GenModuleBinding(cenv cenv, CodeGenBuffer cgbuf, QualifiedNameOfFile qname, List`1 lazyInitInfo, IlxGenEnv eenv, Range m, ModuleOrNamespaceBinding x) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 10080
1>     at FSharp.Compiler.IlxGen.GenModuleOrNamespaceContents(cenv cenv, CodeGenBuffer cgbuf, QualifiedNameOfFile qname, List`1 lazyInitInfo, IlxGenEnv eenv, ModuleOrNamespaceContents x) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 10014
1>     at FSharp.Compiler.IlxGen.GenModuleBinding(cenv cenv, CodeGenBuffer cgbuf, QualifiedNameOfFile qname, List`1 lazyInitInfo, IlxGenEnv eenv, Range m, ModuleOrNamespaceBinding x) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 10080
1>     at FSharp.Compiler.IlxGen.GenModuleOrNamespaceContents(cenv cenv, CodeGenBuffer cgbuf, QualifiedNameOfFile qname, List`1 lazyInitInfo, IlxGenEnv eenv, ModuleOrNamespaceContents x) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 10014
1>     at FSharp.Compiler.IlxGen.GenModuleBinding(cenv cenv, CodeGenBuffer cgbuf, QualifiedNameOfFile qname, List`1 lazyInitInfo, IlxGenEnv eenv, Range m, ModuleOrNamespaceBinding x) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 10080
1>     at FSharp.Compiler.IlxGen.GenModuleOrNamespaceContents(cenv cenv, CodeGenBuffer cgbuf, QualifiedNameOfFile qname, List`1 lazyInitInfo, IlxGenEnv eenv, ModuleOrNamespaceContents x) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 10014
1>     at [email protected](IlxGenEnv eenv, ModuleOrNamespaceContents x)
1>     at Microsoft.FSharp.Collections.ListModule.Fold[T,TState](FSharpFunc`2 folder, TState state, FSharpList`1 list) in D:\a\_work\1\s\src\FSharp.Core\list.fs:line 295
1>     at [email protected](Tuple`2 tupledArg) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 9976
1>     at FSharp.Compiler.IlxGen.LocalScope[a](String nm, CodeGenBuffer cgbuf, FSharpFunc`2 f) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 2813
1>     at [email protected](CodeGenBuffer cgbuf, IlxGenEnv eenv) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 10176
1>     at FSharp.Compiler.IlxGen.CodeGenThen(cenv cenv, AssemblyBuilder mgbuf, FSharpList`1 entryPointInfo, String methodName, IlxGenEnv eenv, Int32 alreadyUsedArgs, FSharpOption`1 selfArgOpt, FSharpFunc`2 codeGenFunction, Range m) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 2743
1>     at FSharp.Compiler.IlxGen.CodeGenMethod(cenv cenv, AssemblyBuilder mgbuf, FSharpList`1 entryPointInfo, String methodName, IlxGenEnv eenv, Int32 alreadyUsedArgs, FSharpOption`1 selfArgOpt, FSharpFunc`2 codeGenFunction, Range m) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 2778
1>     at FSharp.Compiler.IlxGen.GenImplFile(cenv cenv, AssemblyBuilder mgbuf, FSharpOption`1 mainInfoOpt, IlxGenEnv eenv, CheckedImplFileAfterOptimization implFile) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 10166
1>     at [email protected](IlxGenEnv eenv, CheckedImplFileAfterOptimization implFile)
1>     at Microsoft.FSharp.Collections.ListModule.Fold[T,TState](FSharpFunc`2 folder, TState state, FSharpList`1 list) in D:\a\_work\1\s\src\FSharp.Core\list.fs:line 295
1>     at FSharp.Compiler.IlxGen.CodegenAssembly(cenv cenv, IlxGenEnv eenv, AssemblyBuilder mgbuf, FSharpList`1 implFiles) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 11555
1>     at FSharp.Compiler.IlxGen.GenerateCode(cenv cenv, AnonTypeGenerationTable anonTypeTable, IlxGenEnv eenv, CheckedAssemblyAfterOptimization _arg1, FSharpList`1 assemAttribs, FSharpList`1 moduleAttribs) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 11656
1>     at FSharp.Compiler.IlxGen.IlxAssemblyGenerator.GenerateCode(IlxGenOptions codeGenOpts, CheckedAssemblyAfterOptimization typedAssembly, FSharpList`1 assemAttribs, FSharpList`1 moduleAttribs) in D:\a\_work\1\s\src\Compiler\CodeGen\IlxGen.fs:line 11915
1>     at FSharp.Compiler.Driver.main4[a,b,c,d,e](FSharpOption`1 tcImportsCapture, FSharpOption`1 dynamicAssemblyCreator, Args`1 _arg1) in D:\a\_work\1\s\src\Compiler\Driver\fsc.fs:line 1153
1>     at FSharp.Compiler.Driver.CompileFromCommandLineArguments(CompilationThreadToken ctok, String[] argv, LegacyReferenceResolver legacyReferenceResolver, Boolean bannerAlreadyPrinted, ReduceMemoryFlag reduceMemoryUsage, CopyFSharpCoreFlag defaultCopyFSharpCore, Exiter exiter, DiagnosticsLoggerProvider loggerProvider, FSharpOption`1 tcImportsCapture, FSharpOption`1 dynamicAssemblyCreator) in D:\a\_work\1\s\src\Compiler\Driver\fsc.fs:line 1385
1>     at FSharp.Compiler.CommandLineMain.main(String[] argv) in D:\a\_work\1\s\src\fsc\fscmain.fs:line 97
1>     at FSharp.Compiler.DiagnosticsLogger.DiagnosticsLoggerExtensions.ReraiseIfWatsonable(Exception exn) in D:\a\_work\1\s\src\Compiler\Facilities\DiagnosticsLogger.fs:line 403
1>     at FSharp.Compiler.DiagnosticsLogger.DiagnosticsLoggerExtensions.DiagnosticsLogger.ErrorRecovery(DiagnosticsLogger x, Exception exn, Range m) in D:\a\_work\1\s\src\Compiler\Facilities\DiagnosticsLogger.fs:line 457
1>     at FSharp.Compiler.DiagnosticsLogger.errorRecovery(Exception exn, Range m) in D:\a\_work\1\s\src\Compiler\Facilities\DiagnosticsLogger.fs:line 552
1>     at FSharp.Compiler.CommandLineMain.main(String[] argv) in D:\a\_work\1\s\src\fsc\fscmain.fs:line 102
1>Done building target "CoreCompile" in project "WebHost.fsproj" -- FAILED.```

**Known workarounds**

Use old syntax
``` F#
match (^o : (member Validate: unit -> Result< ^o, ValidationErrors>) options) with

Related information

Provide any related information (optional):

  • Windows 11 Pro 10.0.22621
  • .NET Core 7.0.100-rc.2.22477.23
  • Visual Studio 17.4.0 Preview 3.0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions