Skip to content

This code succeeds on desktop fsi, but fails on coreclr fsi #6597

Description

@KevinRansom
[<Struct>]
type ToStringStruct =
  struct
    val x : int
    new(x) = {x=x}
    override this.ToString() = string this.x
  end
let a = new ToStringStruct(123)

With this stackframe:

C:\Users\kevinr\AppData\Local\Temp\3vqfda12.xew>dotnet fsi

Microsoft (R) F# Interactive version 10.4.0 for F# 4.6
Copyright (c) Microsoft Corporation. All Rights Reserved.

For help type #help;;

> [<Struct>]
- type ToStringStruct =
-   struct
-     val x : int
-     new(x) = {x=x}
-     override this.ToString() = string this.x
-   end
- let a = new ToStringStruct(123)
- ;;

Assertion Failed
Unknown exception seen in compiler: System.TypeLoadException: Could not load type 'FSI_0002' from assembly 'FSI-ASSEMBLY, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
   at System.Reflection.Emit.TypeBuilder.TermCreateClass(RuntimeModule module, Int32 tk, ObjectHandleOnStack type)
   at System.Reflection.Emit.TypeBuilder.CreateTypeNoLock()
   at System.Reflection.Emit.TypeBuilder.CreateTypeInfo()
   at FSharp.Compiler.AbstractIL.ILRuntimeWriter.TypeBuilder.CreateTypeAndLog(TypeBuilder ) in C:\kevinransom\visualfsharp\src\absil\ilreflect.fs:line 144
   at FSharp.Compiler.AbstractIL.ILRuntimeWriter.traverseTypeRef@1998.Invoke(ILTypeRef tref) in C:\kevinransom\visualfsharp\src\absil\ilreflect.fs:line 2038
   at Microsoft.FSharp.Primitives.Basics.List.iter[T](FSharpFunc`2 f, FSharpList`1 x) in C:\kevinransom\visualfsharp\src\fsharp\FSharp.Core\local.fs:line 91
   at Microsoft.FSharp.Collections.ListModule.Iterate[T](FSharpFunc`2 action, FSharpList`1 list) in C:\kevinransom\visualfsharp\src\fsharp\FSharp.Core\list.fs:line 111
   at FSharp.Compiler.AbstractIL.ILRuntimeWriter.traverseType@1993.Invoke(CollectTypes allTypes, ILType ty) in C:\kevinransom\visualfsharp\src\absil\ilreflect.fs:line 1993
   at Microsoft.FSharp.Primitives.Basics.List.iter[T](FSharpFunc`2 f, FSharpList`1 x) in C:\kevinransom\visualfsharp\src\fsharp\FSharp.Core\local.fs:line 91
   at Microsoft.FSharp.Collections.ListModule.Iterate[T](FSharpFunc`2 action, FSharpList`1 list) in C:\kevinransom\visualfsharp\src\fsharp\FSharp.Core\list.fs:line 111
   at FSharp.Compiler.AbstractIL.ILRuntimeWriter.traverseTypeDef@1962.Invoke(ILTypeRef tref, ILTypeDef tdef) in C:\kevinransom\visualfsharp\src\absil\ilreflect.fs:line 1988
   at FSharp.Compiler.AbstractIL.ILRuntimeWriter.traverseTypeRef@1998.Invoke(ILTypeRef tref) in C:\kevinransom\visualfsharp\src\absil\ilreflect.fs:line 2007
   at FSharp.Compiler.AbstractIL.ILRuntimeWriter.createTypeRef(Dictionary`2 visited, Dictionary`2 created, emEnv emEnv, ILTypeRef tref) in C:\kevinransom\visualfsharp\src\absil\ilreflect.fs:line 2040
   at FSharp.Compiler.AbstractIL.ILRuntimeWriter.buildTypeDefPass4(Dictionary`2 visited, Dictionary`2 created, FSharpList`1 nesting, emEnv emEnv, ILTypeDef tdef) in C:\kevinransom\visualfsharp\src\absil\ilreflect.fs:line 2045
   at FSharp.Compiler.AbstractIL.ILRuntimeWriter.buildModuleFragment@2083-1.Invoke(ILTypeDef tdef) in C:\kevinransom\visualfsharp\src\absil\ilreflect.fs:line 2083
   at Microsoft.FSharp.Primitives.Basics.List.iter[T](FSharpFunc`2 f, FSharpList`1 x) in C:\kevinransom\visualfsharp\src\fsharp\FSharp.Core\local.fs:line 91
   at Microsoft.FSharp.Collections.ListModule.Iterate[T](FSharpFunc`2 action, FSharpList`1 list) in C:\kevinransom\visualfsharp\src\fsharp\FSharp.Core\list.fs:line 111
   at FSharp.Compiler.AbstractIL.ILRuntimeWriter.buildModuleFragment(cenv cenv, emEnv emEnv, AssemblyBuilder asmB, ModuleBuilder modB, ILModuleDef m) in C:\kevinransom\visualfsharp\src\absil\ilreflect.fs:line 2083
   at FSharp.Compiler.AbstractIL.ILRuntimeWriter.emitModuleFragment(ILGlobals ilg, emEnv emEnv, AssemblyBuilder asmB, ModuleBuilder modB, ILModuleDef modul, Boolean debugInfo, FSharpFunc`2 resolveAssemblyRef, FSharpFunc`2 tryFindSysILTypeRef) in C:\kevinransom\visualfsharp\src\absil\ilreflect.fs:line 2146
   at FSharp.Compiler.Interactive.Shell.FsiDynamicCompiler.ProcessInputs(CompilationThreadToken ctok, ErrorLogger errorLogger, FsiDynamicCompilerState istate, FSharpList`1 inputs, Boolean showTypes, Boolean isIncrementalFragment, Boolean isInteractiveItExpr, FSharpList`1 prefixPath) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 1051
   at FSharp.Compiler.Interactive.Shell.FsiDynamicCompiler.EvalParsedDefinitions(CompilationThreadToken ctok, ErrorLogger errorLogger, FsiDynamicCompilerState istate, Boolean showTypes, Boolean isInteractiveItExpr, FSharpList`1 defs) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 1139
   at FSharp.Compiler.Interactive.Shell.clo@1871-474.Invoke(FsiDynamicCompilerState istate) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 1878
   at FSharp.Compiler.Interactive.Shell.FsiInteractionProcessor.InteractiveCatch[b](ErrorLogger errorLogger, FSharpFunc`2 f, b istate) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 1825

   at FSharp.Compiler.CompileOps.OutputExceptionR@607.Invoke(StringBuilder os, Exception error) in C:\kevinransom\visualfsharp\src\fsharp\CompileOps.fs:line 1581
   at FSharp.Compiler.CompileOps.OutputPhasedErrorR(StringBuilder os, PhasedDiagnostic err, Boolean suggestNames) in C:\kevinransom\visualfsharp\src\fsharp\CompileOps.fs:line 1584
   at FSharp.Compiler.CompileOps.OutputPhasedDiagnostic(StringBuilder os, PhasedDiagnostic err, Boolean flattenErrors, Boolean suggestNames) in C:\kevinransom\visualfsharp\src\fsharp\CompileOps.fs:line 1591
   at FSharp.Compiler.CompileOps.report@1696-1.Invoke(PhasedDiagnostic err) in C:\kevinransom\visualfsharp\src\fsharp\CompileOps.fs:line 1714
   at FSharp.Compiler.CompileOps.CollectDiagnostic(String implicitIncludeDir, Boolean showFullPaths, Boolean flattenErrors, ErrorStyle errorStyle, Boolean warning, PhasedDiagnostic err, Boolean suggestNames) in C:\kevinransom\visualfsharp\src\fsharp\CompileOps.fs:line 1750
   at FSharp.Compiler.CompileOps.OutputDiagnostic(String implicitIncludeDir, Boolean showFullPaths, Boolean flattenErrors, ErrorStyle errorStyle, Boolean isError, StringBuilder os, PhasedDiagnostic err) in C:\kevinransom\visualfsharp\src\fsharp\CompileOps.fs:line 1759
   at FSharp.Compiler.Interactive.Shell.PrintError@510-4.Invoke(StringBuilder arg10@, PhasedDiagnostic arg20@) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 510
   at FSharp.Compiler.Lib.writeViaBufferWithEnvironmentNewLines[a](TextWriter os, FSharpFunc`2 f, a x) in C:\kevinransom\visualfsharp\src\fsharp\lib.fs:line 333
   at FSharp.Compiler.Interactive.Shell.PrintError@507-1.Invoke(Unit unitVar0) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 510
   at FSharp.Compiler.CompileOptions.DoWithColor[a](ConsoleColor newColor, FSharpFunc`2 f) in C:\kevinransom\visualfsharp\src\fsharp\CompileOptions.fs:line 1835
   at FSharp.Compiler.Interactive.Shell.Utilities.ignoreAllErrors(FSharpFunc`2 f) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 87
   at FSharp.Compiler.Interactive.Shell.FsiStdinSyphon.PrintError(TcConfigBuilder tcConfig, PhasedDiagnostic err) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 505
   at FSharp.Compiler.Interactive.Shell.ErrorLoggerThatStopsOnFirstError.DiagnosticSink(PhasedDiagnostic err, Boolean isError) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 546
   at FSharp.Compiler.ErrorLogger.ErrorLoggerExtensions.ErrorLogger.ErrorRecovery(ErrorLogger x, Exception exn, range m) in C:\kevinransom\visualfsharp\src\fsharp\ErrorLogger.fs:line 417
   at FSharp.Compiler.ErrorLogger.ErrorLoggerExtensions.ErrorLogger.StopProcessingRecovery(ErrorLogger x, Exception exn, range m) in C:\kevinransom\visualfsharp\src\fsharp\ErrorLogger.fs:line 431
   at FSharp.Compiler.ErrorLogger.stopProcessingRecovery(Exception exn, range m) in C:\kevinransom\visualfsharp\src\fsharp\ErrorLogger.fs:line 486
   at FSharp.Compiler.Interactive.Shell.FsiInteractionProcessor.InteractiveCatch[b](ErrorLogger errorLogger, FSharpFunc`2 f, b istate) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 1825
   at FSharp.Compiler.Interactive.Shell.FsiInteractionProcessor.ExecInteraction(CompilationThreadToken ctok, TcConfig tcConfig, FsiDynamicCompilerState istate, ParsedFsiInteraction action, ErrorLogger errorLogger) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 1871
   at FSharp.Compiler.Interactive.Shell.FsiInteractionProcessor.execParsedInteractions(CompilationThreadToken ctok, TcConfig tcConfig, FsiDynamicCompilerState istate, FSharpOption`1 action, ErrorLogger errorLogger, FSharpOption`1 lastResult) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 2018
   at FSharp.Compiler.Interactive.Shell.clo@2050-477.Invoke(CompilationThreadToken ctok, TcConfig tcConfig, FsiDynamicCompilerState istate) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 2051
   at FSharp.Compiler.Interactive.Shell.FsiInteractionProcessor.mainThreadProcessAction[a,b](a ctok, FSharpFunc`2 action, b istate) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 2031
   at FSharp.Compiler.Interactive.Shell.FsiInteractionProcessor.mainThreadProcessParsedInteractions(CompilationThreadToken ctok, ErrorLogger errorLogger, FSharpOption`1 action, FsiDynamicCompilerState istate) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 2050
   at FSharp.Compiler.Interactive.Shell.res@2113-58.Invoke(CompilationThreadToken ctok, ErrorLogger errorLogger, Tuple`2 tupledArg) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 2113
   at <StartupCode$FSharp-Compiler-Interactive-Settings>.$Fsiaux.FSharp-Compiler-Interactive-IEventLoop-Invoke@50-1.Invoke(Unit x) in C:\kevinransom\visualfsharp\src\fsharp\fsiaux.fs:line 50
   at <StartupCode$FSharp-Compiler-Interactive-Settings>.$Fsiaux.run@41-4.Invoke(FSharpFunc`2 f) in C:\kevinransom\visualfsharp\src\fsharp\fsiaux.fs:line 41
   at Microsoft.FSharp.Primitives.Basics.List.iter[T](FSharpFunc`2 f, FSharpList`1 x) in C:\kevinransom\visualfsharp\src\fsharp\FSharp.Core\local.fs:line 91
   at Microsoft.FSharp.Collections.ListModule.Iterate[T](FSharpFunc`2 action, FSharpList`1 list) in C:\kevinransom\visualfsharp\src\fsharp\FSharp.Core\list.fs:line 111
   at <StartupCode$FSharp-Compiler-Interactive-Settings>.$Fsiaux.run@39.Invoke(Unit unitVar0) in C:\kevinransom\visualfsharp\src\fsharp\fsiaux.fs:line 41
   at FSharp.Compiler.Interactive.SimpleEventLoop.FSharp-Compiler-Interactive-IEventLoop-Run() in C:\kevinransom\visualfsharp\src\fsharp\fsiaux.fs:line 48
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   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 FSharp.Compiler.Interactive.Shell.Utilities.callInstanceMethod0[a](Object obj, Type[] typeArgs, String nm) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 116
   at Sample.FSharp.Compiler.Interactive.Main.evaluateSession@235-4.EventLoopRun() in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsimain.fs:line 253
   at FSharp.Compiler.Interactive.Shell.runLoop@2356.Invoke(Unit unitVar0) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 2361
   at FSharp.Compiler.Interactive.Shell.DriveFsiEventLoop(FsiEvaluationSessionHostConfig fsi, FsiConsoleOutput fsiConsoleOutput) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 2379
   at FSharp.Compiler.Interactive.Shell.FsiEvaluationSession.Run() in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsi.fs:line 2794
   at Sample.FSharp.Compiler.Interactive.Main.evaluateSession(String[] argv) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsimain.fs:line 305
   at Sample.FSharp.Compiler.Interactive.Main.MainMain(String[] argv) in C:\kevinransom\visualfsharp\src\fsharp\fsi\fsimain.fs:line 339

C:\Users\kevinr\AppData\Local\Temp\3vqfda12.xew>#quit;;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions