diff --git a/vlib/v/scanner/scanner.v b/vlib/v/scanner/scanner.v index 20f852491c..4b933ecf92 100644 --- a/vlib/v/scanner/scanner.v +++ b/vlib/v/scanner/scanner.v @@ -438,7 +438,12 @@ fn (mut s Scanner) ident_dec_number() string { s.pos-- } else { // 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`') } } } diff --git a/vlib/v/scanner/tests/float_literals_dot_err.out b/vlib/v/scanner/tests/float_literals_dot_err.out index 93e9b35b88..05a57905a5 100644 --- a/vlib/v/scanner/tests/float_literals_dot_err.out +++ b/vlib/v/scanner/tests/float_literals_dot_err.out @@ -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() { 2 | a := 1. | ^