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

v2: distinguish public and private constants

This commit is contained in:
Alexey 2020-02-27 00:43:37 +03:00 committed by GitHub
parent 46ec400cb3
commit ca9fa6407f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 0 deletions

View File

@ -89,6 +89,7 @@ pub struct ConstDecl {
pub:
fields []Field
exprs []Expr
is_pub bool
}
pub struct StructDecl {

View File

@ -127,6 +127,9 @@ fn (f mut Fmt) stmt(node ast.Stmt) {
}
}
ast.ConstDecl {
if it.is_pub {
f.write('pub ')
}
f.writeln('const (')
f.indent++
for i, field in it.fields {

View File

@ -18,6 +18,10 @@ const (
pi = 3.14
)
pub const (
i_am_pub_const = true
)
struct User {
name string
age int

View File

@ -19,6 +19,10 @@ const (
pi=3.14
)
pub const (
i_am_pub_const=true
)
struct User {
name string
age int

View File

@ -1369,6 +1369,7 @@ fn (p mut Parser) const_decl() ast.ConstDecl {
return ast.ConstDecl{
fields: fields
exprs: exprs
is_pub: is_pub
}
}