Bug 10314 - [PARSER] Mono parser makes numerous contextual keyword errors
Summary: [PARSER] Mono parser makes numerous contextual keyword errors
Status: NEW
Alias: None
Product: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
: 10094 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-02-14 17:57 UTC by Brett van Swelm
Modified: 2013-03-20 17:35 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 for Bug 10314 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description Brett van Swelm 2013-02-14 17:57:19 UTC
C# has many "conditional" keywords; these are words which have special meaning in the language, but only when found in certain special contexts; outside of those contexts they should be treated as ordinary identifiers.

Any identifier may be prefixed with "@" to make it explicitly an identifier. 

Mono incorrectly requires the @ prefix in many places; I've illustrated each that I've found so far in the code below. This file compiles correctly as-is, but if any single @ is removed then the compiler gives an error. 

In some cases -- particularly the cases involving "partial" -- the errors are bizarre and point to possible other bugs in the Mono parser.

With "D:\Applications\Mono-2.11.4\bin" and "C:\Windows\Microsoft.NET\Framework\v4.0.30319" in the path on my Windows 7 machine:

===== Conditional.cs =====
namespace AsyncProblems
{
    class Classes {
        class async {}
        void M() {
            @async local;
        }
    }

    namespace Namespaces {
        namespace @async {}
    }
}

namespace WhereProblems
{
    // Interestingly enough, this is legal in a generic method and a delegate.
    class MyClass<@where> {}
    interface MyInterface<@where> {}
    struct MyStruct<@where> {}

    class Classes {
        class @where {}
        class DER17 : @where {}
    }
}

namespace FromProblems
{
    class from {}
    class C {
        void M1() {
            @from local = new from();
        }     
        @from M2() {
            return null;
        }
    }
}

namespace PartialProblems
{
    class Classes {
        class partial {}
        void M1(@partial formalParameter) {}

        @partial M3() {
            return null;
        }

        @partial field;
    }

}

namespace AwaitProblems {
    class Formals {
        delegate void D(int x);
        static void M1() {
            D d1 = @await=>{};
            D d2 = (int @await)=>{};
            D d3 = delegate (int @await) {};
        }
    }

    class Methods {
        void await() {}
        void M(Methods m) {
            m.@await();
            this.@await();
            @await();
        }
    }

    class Classes {
        class await {}
        void M()
        {
            @await local = new @await();
        }     
     }

     class AnonTypes {
        static void M() {
            var x = new { @await = 1 };
            var y = x.@await;
        }
    }
}
===== end =====

$ mcs /target:library Conditional.cs 
Conditional.cs(6,20): warning CS0168: The variable `local' is declared but never used
Conditional.cs(33,19): warning CS0219: The variable `local' is assigned but its value is never used
Conditional.cs(60,15): warning CS0219: The variable `d1' is assigned but its value is never used
Conditional.cs(61,15): warning CS0219: The variable `d2' is assigned but its value is never used
Conditional.cs(62,15): warning CS0219: The variable `d3' is assigned but its value is never used
Conditional.cs(79,20): warning CS0219: The variable `local' is assigned but its value is never used
Conditional.cs(51,18): warning CS0169: The private field `PartialProblems.Classes.field' is never used
Compilation succeeded - 7 warning(s)

Thanks,

Brett van Swelm | Senior Engineer
Coverity | 185 Berry Street | Suite 6500, Lobby 3 | San Francisco, CA 94107
The Leader in Development Testing
Read our profile in Forbes, Coverity Gets Code Right 25% Faster
Comment 1 Marek Safar 2013-02-20 16:00:09 UTC
Most errors should be fixed in master
Comment 2 Marek Safar 2013-03-20 17:34:55 UTC
What is still failing is await at first expression statement token

namespace AwaitProblems {
    class Methods {
        void await() {}
        void M(Methods m) {
            await();
        }
    }

    class Classes {
        class await {}
        void M()
        {
            await local = new await();
        }     
     }
}
Comment 3 Marek Safar 2013-03-20 17:35:32 UTC
*** Bug 10094 has been marked as a duplicate of this bug. ***