[Mono-bugs] [Bug 355148] New: Wrong error message when using out argument

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Jan 21 15:34:56 EST 2008


https://bugzilla.novell.com/show_bug.cgi?id=355148


           Summary: Wrong error message when using out argument
           Product: Mono: Compilers
           Version: SVN
          Platform: LittleEndian
        OS/Version: Kubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: mbd at dbc.dk
         QAContact: mono-bugs at lists.ximian.com
          Found By: Other


When compiling this piece of code:

using System;

class A {}
class B : A {}

class ParameterTest {

  static void Foo( out B b ) {
    b = new B();
  }

  static void Main() {
    A a;
    Foo( out a );
  }

}

The output is like this:

$ gmcs /warn:4 OutParams.cs
OutParams.cs(14,5): error CS1502: The best overloaded method match for
`ParameterTest.Foo(out B)' has some invalid arguments
OutParams.cs(8,15): (Location of the symbol related to previous error)
OutParams.cs(14,5): error CS1620: Argument `1' must be passed with the `out'
keyword
Compilation failed: 2 error(s), 0 warnings

This is a very confusing error message, which I also believe is wrong. What the
compiler probably wants to do, is similar to the Windows compiler:

$ csc.exe /warn:4 OutParam.cs
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.42
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.

OutParam.cs(14,5): error CS1502: The best overloaded method match for
'ParameterTest.Foo(out B)' has some invalid arguments
OutParam.cs(14,14): error CS1503: Argument '1': cannot convert from 'out A' to
'out B'


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list