mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: float1 == float2 uses machine epsilon by default
This commit is contained in:

committed by
Alexander Medvednikov

parent
21f9dc6b7c
commit
6d483c0a56
@ -1597,11 +1597,14 @@ fn (p mut Parser) bterm() string {
|
||||
p.expected_type = typ
|
||||
is_str := typ=='string' && !p.is_sql
|
||||
is_ustr := typ=='ustring'
|
||||
is_float := typ=='f64' || typ=='f32'
|
||||
expr_type := typ
|
||||
|
||||
tok := p.tok
|
||||
// if tok in [ .eq, .gt, .lt, .le, .ge, .ne] {
|
||||
if tok == .eq || tok == .gt || tok == .lt || tok == .le || tok == .ge || tok == .ne {
|
||||
p.fgen(' ${p.tok.str()} ')
|
||||
if (is_str || is_ustr) && !p.is_js {
|
||||
if ((is_float && tok == .eq) || (is_str || is_ustr)) && !p.is_js {
|
||||
p.gen(',')
|
||||
}
|
||||
else if p.is_sql && tok == .eq {
|
||||
@ -1655,6 +1658,10 @@ fn (p mut Parser) bterm() string {
|
||||
case Token.lt: p.cgen.set_placeholder(ph, 'ustring_lt(')
|
||||
}
|
||||
}
|
||||
if is_float && tok == .eq {
|
||||
p.gen(')')
|
||||
p.cgen.set_placeholder(ph, '${expr_type}_eq(')
|
||||
}
|
||||
}
|
||||
return typ
|
||||
}
|
||||
|
Reference in New Issue
Block a user