scanner: clarify the float literal warning (#11313)
parent
c954c2834a
commit
4d5521bbf7
|
@ -438,7 +438,12 @@ fn (mut s Scanner) ident_dec_number() string {
|
||||||
s.pos--
|
s.pos--
|
||||||
} else {
|
} else {
|
||||||
// 5.
|
// 5.
|
||||||
s.warn('float literals should have a digit after the decimal point, e.g. `5.0`')
|
mut symbol_length := 0
|
||||||
|
for i := s.pos - 2; i > 0 && s.text[i - 1].is_digit(); i-- {
|
||||||
|
symbol_length++
|
||||||
|
}
|
||||||
|
float_symbol := s.text[s.pos - 2 - symbol_length..s.pos - 1]
|
||||||
|
s.warn('float literals should have a digit after the decimal point, e.g. `${float_symbol}.0`')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
vlib/v/scanner/tests/float_literals_dot_err.vv:2:9: warning: float literals should have a digit after the decimal point, e.g. `5.0`
|
vlib/v/scanner/tests/float_literals_dot_err.vv:2:9: warning: float literals should have a digit after the decimal point, e.g. `1.0`
|
||||||
1 | fn main() {
|
1 | fn main() {
|
||||||
2 | a := 1.
|
2 | a := 1.
|
||||||
| ^
|
| ^
|
||||||
|
|
Loading…
Reference in New Issue