From 667a26335fa69aefc12672e672d700f65b3279c1 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 15 Mar 2021 21:16:23 +0100 Subject: [PATCH] builtin: fix substr() --- vlib/builtin/string.v | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/vlib/builtin/string.v b/vlib/builtin/string.v index 8b2981b181..63eb75df27 100644 --- a/vlib/builtin/string.v +++ b/vlib/builtin/string.v @@ -604,17 +604,17 @@ fn (s string) substr2(start int, _end int, end_max bool) string { // Example: assert 'ABCD'.substr(1,3) == 'BC' pub fn (s string) substr(start int, end int) string { $if !no_bounds_checking ? { - /* - $if debug { - if start > end || start > s.len || end > s.len || start < 0 || end < 0 { - println('substr($start, $end) out of bounds (len=$s.len)') - println('s="$s"') - print_backtrace() - return '' + if start > end || start > s.len || end > s.len || start < 0 || end < 0 { + /* + $if debug { + println('substr($start, $end) out of bounds (len=$s.len)') + println('s="$s"') + print_backtrace() + return '' } + */ + panic('substr($start, $end) out of bounds (len=$s.len)') } - */ - panic('substr($start, $end) out of bounds (len=$s.len)') } len := end - start if len == s.len {