[Mono-devel-list] Critical Bug... Error in Grammar!

Gaurav Vaish gvaish at adobe.com
Fri Mar 28 06:56:49 EST 2003


    The attached program compiles with mcs, while it should not - no
attributes are allowed at namespace level.

<mcs>
gvaish at MASTER /cygdrive/f/gvaish/projects/csdoc/csdoc/src/tests
$ ../mcs/mcs.exe /t:library test_21.cs
Compilation succeeded
</mcs>

<csc>
gvaish at MASTER /cygdrive/f/gvaish/projects/csdoc/csdoc/src/tests
$ csc /nologo /target:library test_21.cs
test_21.cs(4,1): error CS1518: Expected class, delegate, enum, interface, or
struct
</csc>

    This is because of the rule:

<snip file="cs-parser.jay">
namespace_declaration
    : opt_attributes NAMESPACE qualified_identifier
    {
        Attributes attrs = (Attributes) $1;

        if (attrs != null) {
            foreach (AttributeSection asec in attrs.AttributeSections)
            if (asec.Target == "assembly")
                RootContext.AddGlobalAttributeSection (current_container,
asec);
        }

        current_namespace = RootContext.Tree.RecordNamespace
(current_namespace, file, (string) $3);
    }

</snip>

    ... followed by no proper parsing of the attribute checking - I mean,
the attribute should be at the assembly level to be a valid attribute
("[assembly:AttributeName(...)]"). So,

<modified_rule>
    if(asec.Target == "assembly")
        RootContext.AddGlobalAttributeSection(current_container, asec);
    else
        Error("Cannot apply non-assembly attribute to a namespace");
</modified_rule>


    I am unable to open bugzilla for some reasons.. taking too much time to
load! May be someone can file bug on this, and post the bug # on the list.




Happy Hacking,
Gaurav
http://mastergaurav.virtualave.net/iitk
---------------------------------------


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test_21.cs
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20030328/7c87a2a8/attachment.pl 


More information about the Mono-devel-list mailing list