diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 67ab421a2d..68ac4f0197 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -785,7 +785,7 @@ pub fn (c mut Checker) enum_val(node ast.EnumVal) table.Type { c.table.find_type_idx(node.enum_name) } // println('checker: enum_val: $node.enum_name typeidx=$typ_idx') if typ_idx == 0 { - c.error('not an enum (type_idx=0)', node.pos) + c.error('not an enum (name=$node.enum_name) (type_idx=0)', node.pos) } typ := c.table.get_type_symbol(table.Type(typ_idx)) // println('tname=$typ.name') diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 475c4b6227..cf7f95a054 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -58,7 +58,7 @@ pub fn parse_stmt(text string, table &table.Table, scope &ast.Scope) ast.Stmt { pref: &pref.Preferences{} scope: scope // scope: &ast.Scope{start_pos: 0, parent: 0} - + } p.init_parse_fns() p.read_first_token() @@ -82,7 +82,7 @@ pub fn parse_file(path string, table &table.Table, comments_mode scanner.Comment parent: 0 } // comments_mode: comments_mode - + } p.read_first_token() // p.scope = &ast.Scope{start_pos: p.tok.position(), parent: 0} @@ -359,7 +359,7 @@ pub fn (p mut Parser) stmt() ast.Stmt { return ast.ExprStmt{ expr: expr // typ: typ - + } } } @@ -641,7 +641,9 @@ pub fn (p mut Parser) name_expr() ast.Expr { // || p.table.known_type(p.tok.lit)) { return p.struct_init() } - else if p.peek_tok.kind == .dot && p.tok.lit[0].is_capital() { + else if p.peek_tok.kind == .dot && + // + (p.tok.lit[0].is_capital() && !p.scope.known_var(p.tok.lit)) { // `Color.green` mut enum_name := p.check_name() if mod != '' { @@ -657,7 +659,7 @@ pub fn (p mut Parser) name_expr() ast.Expr { p.expr_mod = '' return ast.EnumVal{ enum_name: enum_name // lp.prepend_mod(enum_name) - + val: val pos: p.tok.position() } @@ -796,7 +798,7 @@ pub fn (p mut Parser) expr(precedence int) (ast.Expr,table.Type) { var_name: name fields: fields exprs: vals - pos:p.tok.position() + pos: p.tok.position() } } p.check(.rcbr) @@ -1215,11 +1217,11 @@ fn (p mut Parser) if_expr() ast.Expr { stmts: stmts else_stmts: else_stmts // typ: typ - + pos: pos has_else: has_else // left: left - + } return node } @@ -1645,12 +1647,12 @@ fn (p mut Parser) var_decl_and_assign_stmt() ast.Stmt { return ast.VarDecl{ name: ident.name // name2: name2 - + expr: expr // p.expr(token.lowest_prec) - + is_mut: info0.is_mut // typ: typ - + pos: p.tok.position() } // return p.var_decl(ident[0], exprs[0]) @@ -1788,7 +1790,7 @@ fn (p mut Parser) match_expr() ast.Expr { blocks: blocks match_exprs: match_exprs // typ: typ - + cond: cond } return node