From cddfbf73952a9e0a18d9adf2f2ca5d4076fe0dd8 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 12 Dec 2019 22:57:47 +0300 Subject: [PATCH] parser: allow public types `pub type Foo Bar` --- vlib/compiler/parser.v | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vlib/compiler/parser.v b/vlib/compiler/parser.v index 8f3fa00a2d..9fef070d5a 100644 --- a/vlib/compiler/parser.v +++ b/vlib/compiler/parser.v @@ -447,6 +447,7 @@ fn (p mut Parser) parse(pass Pass) { .key_union, .key_interface { p.struct_decl() } .key_enum { p.enum_decl(false) } + .key_type { p.type_decl() } else { p.error('wrong pub keyword usage') } @@ -734,6 +735,10 @@ fn (p mut Parser) const_decl() { // `type myint int` // `type onclickfn fn(voidptr) int` fn (p mut Parser) type_decl() { + is_pub := p.tok == .key_pub + if is_pub { + p.next() + } p.check(.key_type) name := p.check_name() // V used to have 'type Foo struct', many Go users might use this syntax @@ -757,6 +762,7 @@ fn (p mut Parser) type_decl() { parent: parent.name mod: p.mod cat: .alias + is_public: is_pub }) }