mirror of
https://github.com/vlang/v.git
synced 2025-09-15 10:27:19 -04:00
scanner: fix err pos related to num literals
This commit is contained in:
parent
9888bacad5
commit
aba09a7e4d
5
vlib/v/checker/tests/bin_lit_without_digit_err.out
Normal file
5
vlib/v/checker/tests/bin_lit_without_digit_err.out
Normal file
@ -0,0 +1,5 @@
|
||||
vlib/v/checker/tests/bin_lit_without_digit_err.v:2:14: error: number part of this binary is not provided
|
||||
1 | fn main() {
|
||||
2 | println(0b)
|
||||
| ^
|
||||
3 | }
|
3
vlib/v/checker/tests/bin_lit_without_digit_err.vv
Normal file
3
vlib/v/checker/tests/bin_lit_without_digit_err.vv
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println(0b)
|
||||
}
|
5
vlib/v/checker/tests/bin_lit_wrong_digit_err.out
Normal file
5
vlib/v/checker/tests/bin_lit_wrong_digit_err.out
Normal file
@ -0,0 +1,5 @@
|
||||
vlib/v/checker/tests/bin_lit_wrong_digit_err.v:2:18: error: this binary number has unsuitable digit `2`
|
||||
1 | fn main() {
|
||||
2 | println(0b1112)
|
||||
| ^
|
||||
3 | }
|
3
vlib/v/checker/tests/bin_lit_wrong_digit_err.vv
Normal file
3
vlib/v/checker/tests/bin_lit_wrong_digit_err.vv
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println(0b1112)
|
||||
}
|
5
vlib/v/checker/tests/dec_lit_wrong_digit_err.out
Normal file
5
vlib/v/checker/tests/dec_lit_wrong_digit_err.out
Normal file
@ -0,0 +1,5 @@
|
||||
vlib/v/checker/tests/dec_lit_wrong_digit_err.v:2:18: error: this number has unsuitable digit `q`
|
||||
1 | fn main() {
|
||||
2 | println(12345q)
|
||||
| ^
|
||||
3 | }
|
3
vlib/v/checker/tests/dec_lit_wrong_digit_err.vv
Normal file
3
vlib/v/checker/tests/dec_lit_wrong_digit_err.vv
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println(12345q)
|
||||
}
|
5
vlib/v/checker/tests/float_lit_exp_not_integer_err.out
Normal file
5
vlib/v/checker/tests/float_lit_exp_not_integer_err.out
Normal file
@ -0,0 +1,5 @@
|
||||
vlib/v/checker/tests/float_lit_exp_not_integer_err.v:2:17: error: exponential part should be integer
|
||||
1 | fn main() {
|
||||
2 | println(45e2.5)
|
||||
| ^
|
||||
3 | }
|
3
vlib/v/checker/tests/float_lit_exp_not_integer_err.vv
Normal file
3
vlib/v/checker/tests/float_lit_exp_not_integer_err.vv
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println(45e2.5)
|
||||
}
|
5
vlib/v/checker/tests/float_lit_exp_without_digit_err.out
Normal file
5
vlib/v/checker/tests/float_lit_exp_without_digit_err.out
Normal file
@ -0,0 +1,5 @@
|
||||
vlib/v/checker/tests/float_lit_exp_without_digit_err.v:2:14: error: exponent has no digits
|
||||
1 | fn main() {
|
||||
2 | println(2E)
|
||||
| ^
|
||||
3 | }
|
3
vlib/v/checker/tests/float_lit_exp_without_digit_err.vv
Normal file
3
vlib/v/checker/tests/float_lit_exp_without_digit_err.vv
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println(2E)
|
||||
}
|
5
vlib/v/checker/tests/float_lit_too_many_points_err.out
Normal file
5
vlib/v/checker/tests/float_lit_too_many_points_err.out
Normal file
@ -0,0 +1,5 @@
|
||||
vlib/v/checker/tests/float_lit_too_many_points_err.v:2:19: error: too many decimal points in number
|
||||
1 | fn main() {
|
||||
2 | println(123.45.67)
|
||||
| ^
|
||||
3 | }
|
3
vlib/v/checker/tests/float_lit_too_many_points_err.vv
Normal file
3
vlib/v/checker/tests/float_lit_too_many_points_err.vv
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println(123.45.67)
|
||||
}
|
5
vlib/v/checker/tests/hex_lit_without_digit_err.out
Normal file
5
vlib/v/checker/tests/hex_lit_without_digit_err.out
Normal file
@ -0,0 +1,5 @@
|
||||
vlib/v/checker/tests/hex_lit_without_digit_err.v:2:14: error: number part of this hexadecimal is not provided
|
||||
1 | fn main() {
|
||||
2 | println(0x)
|
||||
| ^
|
||||
3 | }
|
3
vlib/v/checker/tests/hex_lit_without_digit_err.vv
Normal file
3
vlib/v/checker/tests/hex_lit_without_digit_err.vv
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println(0x)
|
||||
}
|
5
vlib/v/checker/tests/hex_lit_wrong_digit_err.out
Normal file
5
vlib/v/checker/tests/hex_lit_wrong_digit_err.out
Normal file
@ -0,0 +1,5 @@
|
||||
vlib/v/checker/tests/hex_lit_wrong_digit_err.v:2:18: error: this hexadecimal number has unsuitable digit `g`
|
||||
1 | fn main() {
|
||||
2 | println(0x111g)
|
||||
| ^
|
||||
3 | }
|
3
vlib/v/checker/tests/hex_lit_wrong_digit_err.vv
Normal file
3
vlib/v/checker/tests/hex_lit_wrong_digit_err.vv
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println(0x111g)
|
||||
}
|
5
vlib/v/checker/tests/oct_lit_without_digit_err.out
Normal file
5
vlib/v/checker/tests/oct_lit_without_digit_err.out
Normal file
@ -0,0 +1,5 @@
|
||||
vlib/v/checker/tests/oct_lit_without_digit_err.v:2:14: error: number part of this octal is not provided
|
||||
1 | fn main() {
|
||||
2 | println(0o)
|
||||
| ^
|
||||
3 | }
|
3
vlib/v/checker/tests/oct_lit_without_digit_err.vv
Normal file
3
vlib/v/checker/tests/oct_lit_without_digit_err.vv
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println(0o)
|
||||
}
|
5
vlib/v/checker/tests/oct_lit_wrong_digit_err.out
Normal file
5
vlib/v/checker/tests/oct_lit_wrong_digit_err.out
Normal file
@ -0,0 +1,5 @@
|
||||
vlib/v/checker/tests/oct_lit_wrong_digit_err.v:2:18: error: this octal number has unsuitable digit `8`
|
||||
1 | fn main() {
|
||||
2 | println(0o1118)
|
||||
| ^
|
||||
3 | }
|
3
vlib/v/checker/tests/oct_lit_wrong_digit_err.vv
Normal file
3
vlib/v/checker/tests/oct_lit_wrong_digit_err.vv
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println(0o1118)
|
||||
}
|
@ -174,9 +174,11 @@ fn (mut s Scanner) ident_bin_number() string {
|
||||
s.pos++
|
||||
}
|
||||
if start_pos + 2 == s.pos {
|
||||
s.pos-- // adjust error position
|
||||
s.error('number part of this binary is not provided')
|
||||
}
|
||||
else if has_wrong_digit {
|
||||
s.pos-- // adjust error position
|
||||
s.error('this binary number has unsuitable digit `${first_wrong_digit.str()}`')
|
||||
}
|
||||
number := filter_num_sep(s.text.str, start_pos, s.pos)
|
||||
@ -203,9 +205,11 @@ fn (mut s Scanner) ident_hex_number() string {
|
||||
s.pos++
|
||||
}
|
||||
if start_pos + 2 == s.pos {
|
||||
s.pos-- // adjust error position
|
||||
s.error('number part of this hexadecimal is not provided')
|
||||
}
|
||||
else if has_wrong_digit {
|
||||
s.pos-- // adjust error position
|
||||
s.error('this hexadecimal number has unsuitable digit `${first_wrong_digit.str()}`')
|
||||
}
|
||||
number := filter_num_sep(s.text.str, start_pos, s.pos)
|
||||
@ -232,9 +236,11 @@ fn (mut s Scanner) ident_oct_number() string {
|
||||
s.pos++
|
||||
}
|
||||
if start_pos + 2 == s.pos {
|
||||
s.pos-- // adjust error position
|
||||
s.error('number part of this octal is not provided')
|
||||
}
|
||||
else if has_wrong_digit {
|
||||
s.pos-- // adjust error position
|
||||
s.error('this octal number has unsuitable digit `${first_wrong_digit.str()}`')
|
||||
}
|
||||
number := filter_num_sep(s.text.str, start_pos, s.pos)
|
||||
@ -335,10 +341,12 @@ fn (mut s Scanner) ident_dec_number() string {
|
||||
}
|
||||
if has_wrong_digit {
|
||||
// error check: wrong digit
|
||||
s.pos-- // adjust error position
|
||||
s.error('this number has unsuitable digit `${first_wrong_digit.str()}`')
|
||||
}
|
||||
else if s.text[s.pos - 1] in [`e`, `E`] {
|
||||
// error check: 5e
|
||||
s.pos-- // adjust error position
|
||||
s.error('exponent has no digits')
|
||||
}
|
||||
else if s.pos < s.text.len && s.text[s.pos] == `.` && !is_range && !is_float_without_fraction && !call_method {
|
||||
|
Loading…
x
Reference in New Issue
Block a user