From 794ee6fc9db83880b27e12be5333a85201c49d13 Mon Sep 17 00:00:00 2001 From: SleepyRoy <47302112+SleepyRoy@users.noreply.github.com> Date: Tue, 25 Feb 2020 01:02:36 +0800 Subject: [PATCH] scanner: fix bin/oct/hex without number parts --- vlib/compiler/scanner.v | 9 +++++++++ vlib/v/scanner/scanner.v | 9 +++++++++ 2 files changed, 18 insertions(+) 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