Skip to content

FS0193: internal error in CheckExpressions #11577

@kerams

Description

@kerams

Repro steps

let z a = Some ("", "", a = "")

Expected behavior

I guess it should error with The union case 'Some' does not have a field named 'a'., because that's what happens for let z a = Some ("", a = "")? Then again, Some takes one parameter and there are 2 unnamed arguments here (from the compiler's perspective), so the whole thing could be interpreted as a tuple.

Actual behavior

error FS0193: internal error: Index was outside the bounds of the array.

Unhandled exception. System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at FSharp.Compiler.CheckExpressions.args$cont@7599-1(TcFileState cenv, TcEnv env, TcGlobals g, AccessorDomain ad, Item item, FSharpList`1 argTys, FSharpList`1 argNames, Int32 numArgTys, FSharpList`1 args, FSharpList`1 unnamedArgs, FSharpList`1 namedCallerArgs, Unit unitVar) in /Users/alfonso/Documents/ncave_fsharp/src/fsharp/CheckExpressions.fs:line 7605
   at FSharp.Compiler.CheckExpressions.TcItemThen(TcFileState cenv, TType overallTy, TcEnv env, UnscopedTyparEnv tpenv, FSharpList`1 tinstEnclosing, Item item, range mItem, FSharpList`1 rest, AfterResolution afterResolution, FSharpList`1 delayed) in /Users/alfonso/Documents/ncave_fsharp/src/fsharp/CheckExpressions.fs:line 7594
   at FSharp.Compiler.CheckExpressions.TcExpr(TcFileState cenv, TType ty, TcEnv env, UnscopedTyparEnv tpenv, SynExpr expr) in /Users/alfonso/Documents/ncave_fsharp/src/fsharp/CheckExpressions.fs:line 5263
   at FSharp.Compiler.ErrorLogger.ErrorLoggerExtensions.ReraiseIfWatsonable(Exception exn) in /Users/alfonso/Documents/ncave_fsharp/src/fsharp/ErrorLogger.fs:line 369
   at FSharp.Compiler.ErrorLogger.ErrorLoggerExtensions.ErrorLogger.ErrorRecovery(ErrorLogger x, Exception exn, range m) in /Users/alfonso/Documents/ncave_fsharp/src/fsharp/ErrorLogger.fs:line 416
   at FSharp.Compiler.CheckExpressions.TcExpr(TcFileState cenv, TType ty, TcEnv env, UnscopedTyparEnv tpenv, SynExpr expr) in /Users/alfonso/Documents/ncave_fsharp/src/fsharp/CheckExpressions.fs:line 5263
   at FSharp.Compiler.CheckExpressions.TcExprFlex(TcFileState cenv, Boolean flex, Boolean compat, TType ty, TcEnv env, UnscopedTyparEnv tpenv, SynExpr e) in /Users/alfonso/Documents/ncave_fsharp/src/fsharp/CheckExpressions.fs:line 5248

(the stack is from Fable's fcs, but I see the same error in VS)

Known workarounds

let z a = Some ("", "", (a = ""))

Related information

Provide any related information (optional):

  • Win 10
  • .NET 5.0.300-preview.21228.15
  • VS 16.10 Preview 3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.good first issuehelp wanted

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions