Dartanalyser produces erros on my listing

Here's some basic enumerated code:

enum Lock {ON, OFF}

void main(){
  var lock = Lock.ON;
  print(lock);

}

      

I can run it, it prints:

Lock.ON

      

But when I run dartanalyser

in my code:

$dartanalyzer enum_demo.dart
Analyzing [enum_demo.dart]...
[error] Expected a method, getter, setter or operator declaration (/Users/nicolasfrancois/Documents/dart/enum_demo.dart, line 1, col 1)
[error] Unexpected token 'enum' (/Users/nicolasfrancois/Documents/dart/enum_demo.dart, line 1, col 1)
[error] Expected a method, getter, setter or operator declaration (/Users/nicolasfrancois/Documents/dart/enum_demo.dart, line 1, col 11)
[error] Unexpected token '{' (/Users/nicolasfrancois/Documents/dart/enum_demo.dart, line 1, col 11)
[error] Variables must be declared using the keywords 'const', 'final', 'var' or a type name (/Users/nicolasfrancois/Documents/dart/enum_demo.dart, line 1, col 12)
[error] Expected to find ';' (/Users/nicolasfrancois/Documents/dart/enum_demo.dart, line 1, col 16)
[error] Unexpected token '}' (/Users/nicolasfrancois/Documents/dart/enum_demo.dart, line 1, col 19)
[error] Expected a method, getter, setter or operator declaration (/Users/nicolasfrancois/Documents/dart/enum_demo.dart, line 1, col 19)
[warning] Undefined class 'Lock' (/Users/nicolasfrancois/Documents/dart/enum_demo.dart, line 1, col 6)
[warning] Undefined name 'Lock' (/Users/nicolasfrancois/Documents/dart/enum_demo.dart, line 5, col 13)
8 errors and 2 warnings found.

      

Is this a bug in the wrong code with my enum?

EDIT: My version of the dart: Dart VM version: 1.8.0 (Thu Nov 27 01:01:55 2014) on "macos_x64"

+3


source to share


1 answer


You must use the undocumented flag:



dartanalyzer --enable-enum enum_demo.dart

      

+6


source







All Articles