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:
parent
46ec400cb3
commit
ca9fa6407f
@ -89,6 +89,7 @@ pub struct ConstDecl {
|
||||
pub:
|
||||
fields []Field
|
||||
exprs []Expr
|
||||
is_pub bool
|
||||
}
|
||||
|
||||
pub struct StructDecl {
|
||||
|
@ -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 {
|
||||
|
@ -18,6 +18,10 @@ const (
|
||||
pi = 3.14
|
||||
)
|
||||
|
||||
pub const (
|
||||
i_am_pub_const = true
|
||||
)
|
||||
|
||||
struct User {
|
||||
name string
|
||||
age int
|
||||
|
@ -19,6 +19,10 @@ const (
|
||||
pi=3.14
|
||||
)
|
||||
|
||||
pub const (
|
||||
i_am_pub_const=true
|
||||
)
|
||||
|
||||
struct User {
|
||||
name string
|
||||
age int
|
||||
|
@ -1369,6 +1369,7 @@ fn (p mut Parser) const_decl() ast.ConstDecl {
|
||||
return ast.ConstDecl{
|
||||
fields: fields
|
||||
exprs: exprs
|
||||
is_pub: is_pub
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user