Error produced for missing var, final, const or type on field declarations.

BUG=2997
TEST=tests/language/field_decl_missing_var_type_test

Review URL: https://chromiumcodereview.appspot.com//10690106

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9585 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
johnniwinther@google.com
2012-07-12 09:22:53 +00:00
parent fdbabb995e
commit 1274e083f5
3 changed files with 23 additions and 1 deletions
@@ -1531,6 +1531,14 @@ class PartialFieldListElement extends VariableListElement {
cachedNode = parse(listener,
getCompilationUnit(),
(p) => p.parseVariablesDeclaration(beginToken));
if (!cachedNode.modifiers.isVar() &&
!cachedNode.modifiers.isFinal() &&
!cachedNode.modifiers.isConst() &&
cachedNode.type === null) {
listener.cancel('A field declaration must start with var, final, '
'const, or a type annotation.',
cachedNode);
}
return cachedNode;
}
-1
View File
@@ -520,7 +520,6 @@ Language/07_Classes/3_Setters_A04_t01: Fail, OK # @compile-error
Language/07_Classes/3_Setters_A04_t02: Fail, OK # @compile-error
Language/07_Classes/3_Setters_A04_t07: Fail, OK # @compile-error
Language/07_Classes/3_Setters_A04_t08: Fail, OK # @compile-error
Language/07_Classes/5_Constructors/1_Generative_Constructors_A01_t02: Fail, OK # @compile-error
Language/07_Classes/5_Constructors/1_Generative_Constructors_A01_t04: Fail, OK # @compile-error
Language/07_Classes/5_Constructors/1_Generative_Constructors_A01_t05: Fail, OK # @compile-error
Language/07_Classes/5_Constructors/1_Generative_Constructors_A03_t05: Fail, OK # @compile-error
@@ -0,0 +1,15 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Dart test program for constructors and initializers.
// Exercises issue 2997, missing var or type on field declarations should
// generate a compile-time error.
class A {
_this; /// 01: compile-time error
A(x) : this._this = x; /// 01: continued
}
main() {
new A(0); /// 01: continued
}