diff --git a/vlib/compiler/scanner.v b/vlib/compiler/scanner.v index 073771d912..3c37340fdc 100644 --- a/vlib/compiler/scanner.v +++ b/vlib/compiler/scanner.v @@ -147,6 +147,9 @@ fn (s mut Scanner) ident_bin_number() string { } s.pos++ } + if start_pos + 2 == s.pos { + s.error('number part of this binary is not provided') + } number := filter_num_sep(s.text.str, start_pos, s.pos) s.pos-- return number @@ -165,6 +168,9 @@ fn (s mut Scanner) ident_hex_number() string { } s.pos++ } + if start_pos + 2 == s.pos { + s.error('number part of this hexadecimal is not provided') + } number := filter_num_sep(s.text.str, start_pos, s.pos) s.pos-- return number @@ -183,6 +189,9 @@ fn (s mut Scanner) ident_oct_number() string { } s.pos++ } + if start_pos + 2 == s.pos { + s.error('number part of this octal is not provided') + } number := filter_num_sep(s.text.str, start_pos, s.pos) s.pos-- return number diff --git a/vlib/v/scanner/scanner.v b/vlib/v/scanner/scanner.v index ac978eaf93..8196eec339 100644 --- a/vlib/v/scanner/scanner.v +++ b/vlib/v/scanner/scanner.v @@ -143,6 +143,9 @@ fn (s mut Scanner) ident_bin_number() string { } s.pos++ } + if start_pos + 2 == s.pos { + s.error('number part of this binary is not provided') + } number := filter_num_sep(s.text.str, start_pos, s.pos) s.pos-- return number @@ -161,6 +164,9 @@ fn (s mut Scanner) ident_hex_number() string { } s.pos++ } + if start_pos + 2 == s.pos { + s.error('number part of this hexadecimal is not provided') + } number := filter_num_sep(s.text.str, start_pos, s.pos) s.pos-- return number @@ -179,6 +185,9 @@ fn (s mut Scanner) ident_oct_number() string { } s.pos++ } + if start_pos + 2 == s.pos { + s.error('number part of this octal is not provided') + } number := filter_num_sep(s.text.str, start_pos, s.pos) s.pos-- return number