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

operator | not defined on bool

This commit is contained in:
Alexander Medvednikov 2019-09-15 19:07:40 +03:00
parent 48c05b5a45
commit 3db4d66824
6 changed files with 27 additions and 18 deletions

View File

@ -15,7 +15,7 @@ ifdef WIN32
$(CC) -std=gnu11 -DUNICODE -D_UNICODE -w -o v0.exe vc/v_win.c
./v0.exe -o v.exe compiler
else
$(CC) -std=gnu11 -w -o v vc/v.c -lm
$(CC) -std=gnu11 -o v vc/v.c -lm
endif
rm -rf vc/
@echo "V has been successfully built"

View File

@ -2052,7 +2052,6 @@ fn (p mut Parser) expression() string {
println('expression() pass=$p.pass tok=')
p.print_tok()
}
p.cgen('/* expr start*/')
ph := p.cgen.add_placeholder()
mut typ := p.term()
is_str := typ=='string'
@ -2123,10 +2122,14 @@ fn (p mut Parser) expression() string {
typ = p.dot(typ, ph)
}
}
// + - |
for p.tok == .plus || p.tok == .minus || p.tok == .pipe || p.tok == .amp || p.tok == .xor {
// + - | ^
for p.tok == .plus || p.tok == .minus || p.tok == .pipe || p.tok == .amp ||
p.tok == .xor {
// for p.tok in [.plus, .minus, .pipe, .amp, .xor] {
tok_op := p.tok
if typ == 'bool' {
p.error('operator ${p.tok.str()} not defined on bool ')
}
is_num := typ == 'void*' || typ == 'byte*' || is_number_type(typ)
p.check_space(p.tok)
if is_str && tok_op == .plus && !p.is_js {

View File

@ -16,7 +16,7 @@
- v ui for linux
- doom.v
+ tcc backend
- fix all c warnings with -pedantic
+ fix all c warnings with -pedantic
+ set up pvs
- ui/orm demo: a simple gui client for postgres/mysql/sqlite
- ui demo: calculator

View File

@ -457,12 +457,12 @@ pub fn filename(path string) string {
// get_line returns a one-line string from stdin
pub fn get_line() string {
str := get_raw_line()
$if windows {
return str.trim_right('\r\n')
}
$else {
return str.trim_right('\n')
}
$if windows {
return str.trim_right('\r\n')
}
$else {
return str.trim_right('\n')
}
}
// get_raw_line returns a one-line string from stdin along with '\n' if there is any
@ -476,16 +476,13 @@ pub fn get_raw_line() string {
return ''
}
$else {
//u64 is used because C.getline needs a size_t as second argument
//Otherwise, it would cause a valgrind warning and may be dangerous
//Malloc takes an int as argument so a cast has to be made
max := u64(256)
buf := malloc(int(max))
max := size_t(256)
buf := *char(malloc(int(max)))
nr_chars := C.getline(&buf, &max, stdin)
if nr_chars == 0 {
return ''
}
return string(buf, nr_chars)
return string(byteptr(buf), nr_chars)
}
}
@ -591,6 +588,9 @@ fn on_segfault(f voidptr) {
}
}
fn C.getpid() int
fn C.proc_pidpath (int, byteptr, int) int
pub fn executable() string {
$if linux {
mut result := malloc(MAX_PATH)
@ -738,6 +738,10 @@ pub fn signal(signum int, handler voidptr) {
C.signal(signum, handler)
}
fn C.fork() int
fn C.wait() int
pub fn fork() int {
$if !windows {
pid := C.fork()

View File

@ -39,7 +39,7 @@ pub fn ls(path string) []string {
if isnil(ent) {
break
}
name := tos_clone(ent.d_name)
name := tos_clone(byteptr(ent.d_name))
if name != '.' && name != '..' && name != '' {
res << name
}

View File

@ -38,6 +38,8 @@ struct C.tm {
tm_sec int
}
fn C.time(int) i64
pub fn now() Time {
t := C.time(0)
mut now := &C.tm{!}