Bug 15520 - error CS1502 && CS1503 while compiling code using a System.DayOfWeek expression. (The same code compiles fine on MS.NET)
Summary: error CS1502 && CS1503 while compiling code using a System.DayOfWeek expressi...
Alias: None
Product: Compilers
Classification: Mono
Component: C# ()
Version: 3.2.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Marek Safar
Depends on:
Reported: 2013-10-19 21:39 UTC by Pablo Ruiz García
Modified: 2013-10-27 03:41 UTC (History)
1 user (show)

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:

Description Pablo Ruiz García 2013-10-19 21:39:36 UTC

Mono's (v3.2.3) GMCS fails to compile the following sample program, which compiles fine using MS.NET compiler:

using System;

namespace Test
 public static class Program {

 static void Main()
        // This two lines are ok..
        var day = DateTime.Now.DayOfWeek - System.DayOfWeek.Monday;
        var span = new TimeSpan(day + 1, 0, 0, 0);

        // This ones fail.. ??
        var day1 = DateTime.Now.DayOfWeek - System.DayOfWeek.Sunday;
        var span1 = new TimeSpan(day1 + 1, 0, 0, 0);                 // error CS1502 && error CS1503

        Console.WriteLine("{0}", span1);


With the following errors:

[builder@host somewhere]$ gmcs -target:exe -out:/tmp/test.exe /tmp/test.cs
/tmp/test.cs(15,14): error CS1502: The best overloaded method match for `System.TimeSpan.TimeSpan(int, int, int, int)' has some invalid arguments
/usr/lib/mono/2.0/mscorlib.dll (Location of the symbol related to previous error)
/tmp/test.cs(15,27): error CS1503: Argument `#1' cannot convert `System.DayOfWeek' expression to type `int'
Compilation failed: 2 error(s), 0 warnings

What is funny about this error is that is looks like only fails when an implicit conversion of a DayOfWeek expression (derived from Sunday) is requested, it doesnt fail with Monday. 

Apparently GMCS doesnt want to talk about working on Sundays.. ;)
Comment 1 Marek Safar 2013-10-27 03:41:19 UTC
Fixed in master