mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: remove parenthesis around single ident (#9696)
This commit is contained in:
parent
9427c5f526
commit
ada763e0f4
@ -270,7 +270,7 @@ pub fn (mut a array) pop() voidptr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
new_len := a.len - 1
|
new_len := a.len - 1
|
||||||
last_elem := unsafe { &byte(a.data) + (new_len) * a.element_size }
|
last_elem := unsafe { &byte(a.data) + new_len * a.element_size }
|
||||||
a.len = new_len
|
a.len = new_len
|
||||||
// NB: a.cap is not changed here *on purpose*, so that
|
// NB: a.cap is not changed here *on purpose*, so that
|
||||||
// further << ops on that array will be more efficient.
|
// further << ops on that array will be more efficient.
|
||||||
|
@ -43,7 +43,7 @@ fn test_between() {
|
|||||||
fn test_compare() {
|
fn test_compare() {
|
||||||
a := 'Music'
|
a := 'Music'
|
||||||
b := 'src'
|
b := 'src'
|
||||||
assert b >= (a)
|
assert b >= a
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_lt() {
|
fn test_lt() {
|
||||||
@ -53,12 +53,12 @@ fn test_lt() {
|
|||||||
d := 'b'
|
d := 'b'
|
||||||
e := 'aa'
|
e := 'aa'
|
||||||
f := 'ab'
|
f := 'ab'
|
||||||
assert a < (b)
|
assert a < b
|
||||||
assert !(b < c)
|
assert !(b < c)
|
||||||
assert c < (d)
|
assert c < d
|
||||||
assert !(d < e)
|
assert !(d < e)
|
||||||
assert c < (e)
|
assert c < e
|
||||||
assert e < (f)
|
assert e < f
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_ge() {
|
fn test_ge() {
|
||||||
@ -67,11 +67,11 @@ fn test_ge() {
|
|||||||
c := 'ab'
|
c := 'ab'
|
||||||
d := 'abc'
|
d := 'abc'
|
||||||
e := 'aaa'
|
e := 'aaa'
|
||||||
assert b >= (a)
|
assert b >= a
|
||||||
assert c >= (b)
|
assert c >= b
|
||||||
assert d >= (c)
|
assert d >= c
|
||||||
assert !(c >= d)
|
assert !(c >= d)
|
||||||
assert e >= (a)
|
assert e >= a
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_compare_strings() {
|
fn test_compare_strings() {
|
||||||
|
@ -188,7 +188,7 @@ const (
|
|||||||
const (
|
const (
|
||||||
sublang_neutral = 0x00
|
sublang_neutral = 0x00
|
||||||
sublang_default = 0x01
|
sublang_default = 0x01
|
||||||
lang_neutral = (sublang_neutral)
|
lang_neutral = sublang_neutral
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ref - https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--12000-15999-
|
// Ref - https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--12000-15999-
|
||||||
|
@ -2157,11 +2157,16 @@ pub fn (mut f Fmt) or_expr(node ast.OrExpr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut f Fmt) par_expr(node ast.ParExpr) {
|
pub fn (mut f Fmt) par_expr(node ast.ParExpr) {
|
||||||
f.write('(')
|
requires_paren := node.expr !is ast.Ident
|
||||||
f.par_level++
|
if requires_paren {
|
||||||
|
f.par_level++
|
||||||
|
f.write('(')
|
||||||
|
}
|
||||||
f.expr(node.expr)
|
f.expr(node.expr)
|
||||||
f.par_level--
|
if requires_paren {
|
||||||
f.write(')')
|
f.par_level--
|
||||||
|
f.write(')')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut f Fmt) postfix_expr(node ast.PostfixExpr) {
|
pub fn (mut f Fmt) postfix_expr(node ast.PostfixExpr) {
|
||||||
|
3
vlib/v/fmt/tests/par_expr_expected.vv
Normal file
3
vlib/v/fmt/tests/par_expr_expected.vv
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
_ := (cond1 && cond2) || single_ident
|
||||||
|
}
|
3
vlib/v/fmt/tests/par_expr_input.vv
Normal file
3
vlib/v/fmt/tests/par_expr_input.vv
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
_ := (cond1 && cond2) || (single_ident)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user