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

fmt: proper infix operator detection in wrapping logic (#9824)

This commit is contained in:
Lukas Neubert
2021-04-20 14:20:11 +02:00
committed by GitHub
parent 254d247e80
commit f5e6cadf63
2 changed files with 20 additions and 12 deletions

View File

@ -2,3 +2,14 @@ fn infix_in_multi_assign() {
child_width, child_height = child.adj_width + child.margin(.left) + child.margin(.right),
child.adj_height + child.margin(.top) + child.margin(.bottom)
}
fn impostor_infix() {
/*
String concatiation is an InfixExpr. The second part is so long
that it overflows a single line. Therefore the wrapping logic is run.
The problem was that `&&` and `||` inside the string were detected as infix operators.
Thus causing a totally wrong wrapping and sometimes runtime panics.
*/
x := 'foo' +
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || (eeeeeeeeeeeeeeeeee && ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) && bbbbbbbbbbbbbbbbbbbbbbbbbbbb'
}