Bug 14961 - Redefining the Option type causes fsharpi crashes but in VS 2012's F# interactive things work.
Summary: Redefining the Option type causes fsharpi crashes but in VS 2012's F# interac...
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: Other ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Rodrigo Kumpera
URL:
Depends on:
Blocks:
 
Reported: 2013-09-24 15:45 UTC by César
Modified: 2014-05-28 15:19 UTC (History)
5 users (show)

Tags: fsharp
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description César 2013-09-24 15:45:02 UTC
While using fsharpi and the F# Interactive in XS, when redefining the Option<'a> type causes runtime errors.

Software and hardware setup:

OSX 10.8.5

Mono JIT compiler version 3.2.0 ((no/7c7fcc7 Tue Jul 23 19:59:39 EDT 2013)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: altstack
Notification: kqueue
Architecture: x86
Disabled: none
Misc: softdebug
LLVM: yes(3.3svn-mono)
GC: sgen

Steps to reproduce:
1. Run fsharpi with Mono on OSX
2. Define the following DU and function:

type Option<'a> =
    | Some of 'a
    | None

let printKind something =
    match something with
    | Some x -> x.GetType().Name
    | None -> "Nothing"
Run the following invocations:
printKind (Some 1);;

val it : string = "Int32"

printKind (Some 1.0);;

val it : string = "Double"

printKind (Some "string");;

System.TypeInitializationException: An exception was thrown by the type initializer for Option`1 ---> System.NullReferenceException: Object reference not set to an instance of an object
  at FSI_0035+Option`1[System.String]..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at <StartupCode$FSI_0038>.$FSI_0038.main@ () [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
Stopped due to error

printKind None;;

System.TypeInitializationException: An exception was thrown by the type initializer for Option`1 ---> System.NullReferenceException: Object reference not set to an instance of an object
  at FSI_0035+Option`1[System.Object]..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at <StartupCode$FSI_0039>.$FSI_0039.main@ () [0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
Stopped due to error


The same invocations and definitions on VS 2012 yields the following results:

printKind (Some 1);;
val it : string = "Int32"

printKind (Some 1.0);;
val it : string = "Double"

printKind None;;
val it : string = "Nothing"
Comment 1 donsyme 2013-09-24 16:03:09 UTC
This looks like a recent regression in Mono core runtime components.

It is a Mono Runtime bug, not a compiler bug.
Comment 2 Andres G. Aragoneses 2013-09-25 06:49:50 UTC
If it is a regression, Cesar: could you try git-bisecting?
Comment 3 Cody Russell 2014-05-28 15:19:11 UTC
This has been fixed in the latest release.