Bug 30245 - Exception raised during pretty printing when using Lazy List with Cons and Nil. Works with "int" but not with "string" (F#)
Summary: Exception raised during pretty printing when using Lazy List with Cons and Ni...
Status: RESOLVED FIXED
Alias: None
Product: Installers
Classification: Mono
Component: General ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Rodrigo Kumpera
URL:
Depends on:
Blocks:
 
Reported: 2015-05-19 17:32 UTC by gentauro
Modified: 2015-06-29 18:25 UTC (History)
4 users (show)

Tags:
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 gentauro 2015-05-19 17:32:22 UTC
--------------------------------------------------------------------------------
Mono version:
--------------------------------------------------------------------------------
[ mon@mbai7 ~ ] mono --version
Mono JIT compiler version 4.0.0 ((detached/d136b79 Mon Apr 13 14:40:59 EDT 2015)
Copyright (C) 2002-2014 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.6.0svn-mono-(detached/a173357)
	GC:            sgen
--------------------------------------------------------------------------------
FSI version
--------------------------------------------------------------------------------
[ mon@mbai7 ~ ] fsi

F# Interactive for F# 3.1 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License

For help type #help;;

> 
--------------------------------------------------------------------------------
Issue: Following code works on a PC with Windows and .NET 4.5.2
--------------------------------------------------------------------------------
> type 'a ListLazy = Cons of 'a * 'a ListLazy Lazy | Nil;;

type 'a ListLazy =
  | Cons of 'a * Lazy<'a ListLazy>
  | Nil

> Cons(42,lazy Nil);;                          
val it : int ListLazy = Cons (42,Value is not created.)

> Cons("42",lazy Nil);;

Exception raised during pretty printing.
Please report this so it can be fixed.
Trace: System.InvalidCastException: Cannot cast from source type to destination type.
  at (wrapper castclass) object:__castclass_with_cache (object,intptr,intptr)
  at Microsoft.FSharp.Compiler.Interactive.Shell+Utilities+AnyToLayoutSpecialization`1[FSI_0002+ListLazy`1[System.String]].Microsoft-FSharp-Compiler-Interactive-Shell-Utilities-IAnyToLayoutCall-AnyToLayout (Internal.Utilities.StructuredFormat.FormatOptions options, System.Object o) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Compiler.Interactive.Shell+FsiValuePrinter.PrintValue (Microsoft.FSharp.Compiler.Interactive.FsiValuePrinterMode printMode, Internal.Utilities.StructuredFormat.FormatOptions opts, System.Object x, System.Type ty) [0x00000] in <filename unknown>:0 
val it : string ListLazy = 
> 
--------------------------------------------------------------------------------
Comment 1 Chris Hamons 2015-06-03 08:37:26 UTC
This appears to be an F# bug, not something specific to the MonoMac bindings. I've moved it to here:

https://github.com/fsharp/fsharp/issues/417
Comment 2 donsyme 2015-06-24 01:48:23 UTC
Hi Chris

I'm pretty sure this is a Mono bug because the code works OK on Windows. The F# code is doing a cast at runtime during pretty printing.

Perhaps the problem is to do with generic code sharing in dynamically generated F# code (i.e. Reflection Emit code)

Don
Comment 3 Chris Hamons 2015-06-24 10:19:47 UTC
@donsyme - MonoMac != Mono for Mac. MonoMac is the open source bindings to write GUI applications and package them for the Mac.

I'll re-open and assign to the general mono queue.
Comment 4 obadz 2015-06-25 04:41:37 UTC
$ /nix/store/0bzjkvlbiy2sjazhzlj5br8qhpg1sa4g-mono-git-ad600a087f/bin/mono /nix/store/78ghchw8lxw25fqh70xmi007pz2xs32r-fsharp-3.1.1.32/lib/mono/4.5/fsi.exe 

F# Interactive for F# 3.1 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License

For help type #help;;

> type 'a ListLazy = Cons of 'a * 'a ListLazy Lazy | Nil;;

type 'a ListLazy =
  | Cons of 'a * Lazy<'a ListLazy>
  | Nil

> Cons(42,lazy Nil);;                   
val it : int ListLazy = Cons (42,Value is not created.)
> Cons("42",lazy Nil);;
val it : string ListLazy = Cons ("42",Value is not created.)
> 

Fixed by https://github.com/mono/mono/pull/1654
Comment 5 Rodrigo Kumpera 2015-06-29 18:25:52 UTC
The PR in question was merged.