make necessary consts public

pull/2463/head
Alexander Medvednikov 2019-10-24 12:36:57 +03:00
parent 1c564bc118
commit dce3275df4
6 changed files with 9 additions and 6 deletions

View File

@ -9,7 +9,7 @@ import (
strings strings
) )
const ( pub const (
Version = '0.1.21' Version = '0.1.21'
) )

View File

@ -1850,7 +1850,7 @@ fn (p mut Parser) name_expr() string {
return p.get_const_type(name, ptr) return p.get_const_type(name, ptr)
} }
// Function (not method btw, methods are handled in dot()) // Function (not method, methods are handled in `.dot()`)
mut f := p.table.find_fn_is_script(name, p.v_script) or { mut f := p.table.find_fn_is_script(name, p.v_script) or {
return p.get_undefined_fn_type(name, orig_name) return p.get_undefined_fn_type(name, orig_name)
} }
@ -1964,6 +1964,9 @@ fn (p mut Parser) get_const_type(name string, is_ptr bool) string {
// c.ptr = true // c.ptr = true
p.gen('& /*const*/ ') p.gen('& /*const*/ ')
} }
if !c.is_public && c.mod != p.mod {
p.warn('constant `$c.name` is private')
}
mut typ := p.var_expr(c) mut typ := p.var_expr(c)
if is_ptr { if is_ptr {
typ += '*' typ += '*'

View File

@ -1,6 +1,6 @@
module compiler module compiler
const ( pub const (
help_text = 'Usage: v [options/commands] [file.v | directory] help_text = 'Usage: v [options/commands] [file.v | directory]
When V is run without any arguments, it is run in REPL mode. When V is run without any arguments, it is run in REPL mode.

View File

@ -26,7 +26,7 @@ struct C.dirent {
fn C.readdir(voidptr) C.dirent fn C.readdir(voidptr) C.dirent
const ( pub const (
args = []string args = []string
MAX_PATH = 4096 MAX_PATH = 4096
) )

View File

@ -3,7 +3,7 @@ module os
#include <dirent.h> #include <dirent.h>
#include <unistd.h> #include <unistd.h>
const ( pub const (
path_separator = '/' path_separator = '/'
) )

View File

@ -3,7 +3,7 @@ module os
#flag -lws2_32 #flag -lws2_32
#include <winsock2.h> #include <winsock2.h>
const ( pub const (
path_separator = '\\' path_separator = '\\'
) )