1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: uniform handling of enum field format

This commit is contained in:
yuyi 2020-04-30 18:18:16 +08:00 committed by GitHub
parent 81ed6ad2a1
commit 5481c0fc84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 16 deletions

View File

@ -1,14 +1,14 @@
vlib/v/checker/tests/enum_err.v:4:13: error: default value for enum has to be an integer
2|
3| enum Color {
4| green = 'green',
4| green = 'green'
~~~~~~~
5| yellow = 1+1,
6| blue,
5| yellow = 1+1
6| blue
vlib/v/checker/tests/enum_err.v:5:14: error: default value for enum has to be an integer
3| enum Color {
4| green = 'green',
5| yellow = 1+1,
4| green = 'green'
5| yellow = 1+1
~~~
6| blue,
6| blue
7| }

View File

@ -1,9 +1,9 @@
module main
enum Color {
green = 'green',
yellow = 1+1,
blue,
green = 'green'
yellow = 1+1
blue
}
fn main(){

View File

@ -1126,13 +1126,6 @@ fn (mut p Parser) enum_decl() ast.EnumDecl {
expr: expr
has_expr: has_expr
}
// Allow commas after enum, helpful for
// enum Color {
// r,g,b
// }
if p.tok.kind == .comma {
p.next()
}
}
p.check(.rcbr)
p.table.register_type_symbol(table.TypeSymbol{