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

fmt: use -1 for *really* no precedence, since & and | have precedence 0

This commit is contained in:
Uwe Krüger 2020-06-25 02:39:33 +02:00 committed by GitHub
parent 3bb6b6c8b2
commit bdecbc1945
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -145,7 +145,7 @@ fn (mut f Fmt) adjust_complete_line() {
for i, buf in f.expr_bufs {
// search for low penalties
if i == 0 || f.penalties[i-1] <= 1 {
precedence := if i == 0 { 0 } else { f.precedences[i-1] }
precedence := if i == 0 { -1 } else { f.precedences[i-1] }
mut len_sub_expr := if i == 0 { buf.len + f.line_len } else { buf.len }
mut sub_expr_end_idx := f.penalties.len
// search for next position with low penalty and same precedence to form subexpression

View File

@ -70,3 +70,7 @@ fn (mut p Parser) name_expr() {
println(p.peek_tok.lit)
}
}
fn set_nr_muls(t table.Type, nr_muls int) table.Type {
return int(t) & 0xff00ffff | (nr_muls << 16)
}

View File

@ -82,3 +82,8 @@ fn (mut p Parser) name_expr() {
println(p.peek_tok.lit)
}
}
fn set_nr_muls(t table.Type, nr_muls int) table.Type {
return int(t) &
0xff00ffff | (nr_muls << 16)
}