Bug 32054 - Internal compiler error using Null Coalescing Operator on System.Nullable
Summary: Internal compiler error using Null Coalescing Operator on System.Nullable
Status: RESOLVED FIXED
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: 4.0.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2015-07-16 19:20 UTC by João Vitor
Modified: 2015-08-26 02:01 UTC (History)
2 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 João Vitor 2015-07-16 19:20:25 UTC
Code:

    class Test
    {
        int? _state;
        public bool Working() => _state?.ToString() != "";
    }


Error:
Test.cs(34,34): Error CS0584: Internal compiler error: /Users/joao/Projects/test/TestNullable/Test.cs(9,34): Mono.CSharp.Nullable.Unwrap ExprClass is Invalid after resolve (CS0584) (TestNullable)


=== Xamarin Studio ===

Version 5.9.4 (build 5)
Installation UUID: 0dca64e4-d900-4836-b697-c381adbe2408
Runtime:
	Mono 4.0.2 ((detached/c99aa0c)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400020005

=== Xamarin.Android ===

Version: 5.1.4.16 (Indie Edition)
Android SDK: /Users/joao/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.4   (API level 19)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Not Installed

=== Apple Developer Tools ===

Xcode 6.4 (7720)
Build 6E35b

=== Xamarin.Mac ===

Not Installed

=== Xamarin.iOS ===

Version: 8.10.3.2 (Indie Edition)
Hash: 8b265d6
Branch: master
Build date: 2015-06-30 15:19:13-0400

=== Build Information ===

Release ID: 509040005
Git revision: 8010a90f6e246b32364e3fb46ef2c9d1be9c9a2b
Build date: 2015-06-08 16:52:06-04
Xamarin addins: 7e93e9c3503f28770f23ce1b7eafd829919f18e8

=== Operating System ===

Mac OS X 10.10.4
Darwin Joaos-MacBook-Pro.local 14.4.0 Darwin Kernel Version 14.4.0
    Thu May 28 11:35:04 PDT 2015
    root:xnu-2782.30.5~1/RELEASE_X86_64 x86_64
Comment 1 Marek Safar 2015-07-20 12:44:02 UTC
Fixed in master and Mono 4.2
Comment 2 João Vitor 2015-08-23 12:22:12 UTC
On another instance the code does compile, but I receive "Invalid IL code" when trying to run the method that uses ?. on Nullable.

I'm assuming this is the same bug, and it was fixed as well.

Method that generates invalid IL code:

        public static Vector2 GetSpeedMultiplier(this Terrain terrain)
        {
            return terrain?.Properties.Get("speed_multiplier")?.AsVector2() ?? Vector2.One;
        }

Equivalent method that does work:

        public static Vector2 GetSpeedMultiplier(this Terrain terrain)
        {
            if (terrain == null)
                return Vector2.One;
            var multiplier = terrain.Properties.Get("speed_multiplier");
            if (multiplier == null)
                return Vector2.One;
            var vector = multiplier.Value.AsVector2();
            if (vector == null)
                return Vector2.One;
            
            return vector.Value;
        }

Terrain in a class,
both Property and Vector2 are structs.

Should I report another bug?

System.InvalidProgramException: Invalid IL code in Core.Model.GamePlay.Extensions:GetSpeedMultiplier (FuncWorks.XNA.XTiled.Terrain): IL_0044: call      0x06000078


  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (object) [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1006
  at at MonoMac.AppKit.AppKitSynchronizationContext/<Post>c__AnonStorey0.<>m__0 () <IL 0x0000c, 0x00032>
  at at MonoMac.Foundation.NSAsyncActionDispatcher.Apply () <IL 0x00008, 0x0003c>
  at at (wrapper dynamic-method) object.[MonoMac.Foundation.NSAsyncActionDispatcher.Void Apply()] (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector) <IL 0x0000b, 0x0004f>
  at at (wrapper native-to-managed) object.[MonoMac.Foundation.NSAsyncActionDispatcher.Void Apply()] (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector) <IL 0x00057, 0x0012b>
  at at (wrapper managed-to-native) MonoMac.AppKit.NSApplication.NSApplicationMain (int,string[]) <0x00012>
  at at MonoMac.AppKit.NSApplication.Main (string[]) <IL 0x00041, 0x00107>
  at Mac.Blue.Program.Main (string[]) [0x0001d] in /Users/joao/Projects/jvlppm/game-test/Targets/Mac/Blue/Main.cs:24


=== Xamarin Studio ===

Version 5.9.5 (build 10)
Installation UUID: 0dca64e4-d900-4836-b697-c381adbe2408
Runtime:
	Mono 4.0.3 ((detached/d6946b4)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 400030020

=== Apple Developer Tools ===

Xcode 6.4 (7720)
Build 6E35b

=== Xamarin.iOS ===

Version: 8.10.4.46 (Indie Edition)
Hash: 2c66d2f
Branch: master
Build date: 2015-08-04 13:52:25-0400

=== Xamarin.Android ===

Version: 5.1.5.3 (Indie Edition)
Android SDK: /Users/joao/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.4   (API level 19)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Not Installed

=== Xamarin.Mac ===

Not Installed

=== Build Information ===

Release ID: 509050010
Git revision: 48d16bc4f12ce3938964fc7c3d72fdc6887ad4ad
Build date: 2015-08-18 16:55:24-04
Xamarin addins: c2d51b360ad9f59e689046d47030df27de28f94a

=== Operating System ===

Mac OS X 10.10.4
Darwin Joaos-MacBook-Pro.local 14.4.0 Darwin Kernel Version 14.4.0
    Thu May 28 11:35:04 PDT 2015
    root:xnu-2782.30.5~1/RELEASE_X86_64 x86_64
Comment 3 Jahmai 2015-08-26 02:01:49 UTC
Another C#6 issue that should be back patched to 4.0.

This is a straight up lie:

https://developer.xamarin.com/guides/cross-platform/advanced/csharp_six/

"This document introduces the new features of C# 6.0. C# 6 is fully supported by the mono compiler and developers can start using the new features across all the Xamarin target platforms."

"The Mono C# 6 compiler is included in Mono 4.0 and later, which is freely available for download. Xamarin Studio automatically updates the Mono installation on your system."

Yet there are 2 breaking issues with auto properties and also this issue.

All these issues should be hotfixed to 4.0, or 4.2 should be put into the stable branch as early as possible.