vala r1469 - in trunk: . vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1469 - in trunk: . vala
- Date: Wed, 28 May 2008 19:47:10 +0000 (UTC)
Author: juergbi
Date: Wed May 28 19:47:10 2008
New Revision: 1469
URL: http://svn.gnome.org/viewvc/vala?rev=1469&view=rev
Log:
2008-05-28 Juerg Billeter <j bitron ch>
* vala/valanamespace.vala:
* vala/valaparser.vala:
Report error when using invalid modifiers for methods and fields,
based on patch by Jared Moore, fixes bug 534018
Modified:
trunk/ChangeLog
trunk/vala/valanamespace.vala
trunk/vala/valaparser.vala
Modified: trunk/vala/valanamespace.vala
==============================================================================
--- trunk/vala/valanamespace.vala (original)
+++ trunk/vala/valanamespace.vala Wed May 28 19:47:10 2008
@@ -293,6 +293,16 @@
* @param f a field
*/
public void add_field (Field f) {
+ if (f.binding == MemberBinding.INSTANCE) {
+ Report.error (f.source_reference, "instance members are not allowed outside of data types");
+ f.error = true;
+ return;
+ } else if (f.binding == MemberBinding.CLASS) {
+ Report.error (f.source_reference, "class members are not allowed outside of classes");
+ f.error = true;
+ return;
+ }
+
fields.add (f);
scope.add (f.name, f);
}
@@ -305,13 +315,15 @@
public void add_method (Method m) {
if (m is CreationMethod) {
Report.error (m.source_reference, "construction methods may only be declared within classes and structs");
-
m.error = true;
return;
}
if (m.binding == MemberBinding.INSTANCE) {
- Report.error (m.source_reference, "instance methods not allowed outside of data types");
-
+ Report.error (m.source_reference, "instance members are not allowed outside of data types");
+ m.error = true;
+ return;
+ } else if (m.binding == MemberBinding.CLASS) {
+ Report.error (m.source_reference, "class members are not allowed outside of classes");
m.error = true;
return;
}
Modified: trunk/vala/valaparser.vala
==============================================================================
--- trunk/vala/valaparser.vala (original)
+++ trunk/vala/valaparser.vala Wed May 28 19:47:10 2008
@@ -1867,11 +1867,17 @@
ns.add_delegate ((Delegate) sym);
} else if (sym is Method) {
var method = (Method) sym;
- method.binding = MemberBinding.STATIC;
+ if (method.binding == MemberBinding.INSTANCE) {
+ // default to static member binding
+ method.binding = MemberBinding.STATIC;
+ }
ns.add_method (method);
} else if (sym is Field) {
var field = (Field) sym;
- field.binding = MemberBinding.STATIC;
+ if (field.binding == MemberBinding.INSTANCE) {
+ // default to static member binding
+ field.binding = MemberBinding.STATIC;
+ }
ns.add_field (field);
} else if (sym is Constant) {
ns.add_constant ((Constant) sym);
@@ -2028,6 +2034,11 @@
} else if (ModifierFlags.CLASS in flags) {
f.binding = MemberBinding.CLASS;
}
+ if (ModifierFlags.ABSTRACT in flags
+ || ModifierFlags.VIRTUAL in flags
+ || ModifierFlags.OVERRIDE in flags) {
+ Report.error (f.source_reference, "abstract, virtual, and override modifiers are not applicable to fields");
+ }
if (accept (TokenType.ASSIGN)) {
f.initializer = parse_expression ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]