$ v doctor
OS: linux, Linux Mint 19 Tara
Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
CC version: cc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
getwd: /home/glenn/src/github.com/vlang/v/vlib/regex
vmodules: /home/glenn/.vmodules
vroot: /home/glenn/src/github.com/vlang/v
vexe: /home/glenn/src/github.com/vlang/v/v
vexe mtime: 2020-12-09 21:07:44
is vroot writable: true
is vmodules writable: true
V full version: V 0.1.30 4a35a75
Git version: git version 2.17.1
Git vroot status: weekly.2020.49.5-113-g4a35a75b-dirty
.git/config present: true
thirdparty/tcc status: thirdparty-linux-amd64 7543de81
What did you do?
I added the following unit test to vlib/regex/regex_test.v:
diff --git a/vlib/regex/regex_test.v b/vlib/regex/regex_test.v
index aa5d334b..5e34d583 100644
--- a/vlib/regex/regex_test.v
+++ b/vlib/regex/regex_test.v
@@ -202,6 +202,12 @@ cgroups_test_suite = [
[0, 3, 4, 5, 5, 7],
map[string]int{}
},
+ TestItemCGroup{
+ "8-11 l: qllllqllklhlvtl",
+ r"^(\d+)-(\d+) ([a-z]): (.*)$",0,23,
+ [0, 1, 2, 4, 5, 6, 8, 23],
+ map[string]int{}
+ },
]
)
What did you expect to see?
I expected the new unit test to pass.
What did you see instead?
The test fails, with this output:
$ v test .
--------------------------------------------------------- Testing... -------------------------------------------------------
FAIL 182.089 ms regex_test.v
Capture group doesn't match:
true ground: [[0, 1, 2, 4, 5, 6, 8, 23]]
elaborated : [[0, 1, 2, 4, 5, 6, 8, 9]]
/home/glenn/src/github.com/vlang/v/vlib/regex/regex_test.v:288: failed assert in function test_regex
Source : `false`
----------------------------------------------------------------------------------------------------------------------------
182.589 ms <=== total time spent running V _test.v files
ok, fail, skip, total = 0, 1, 0, 1
I also noticed that the * appears to be ignored after PC: 14 below:
========================================
v RegEx compiler v 0.9h output:
PC: 0 ist: 92000000 ( GROUP_START #:0 { 1, 1}
PC: 1 ist: 90000000 [\d] BSLS { 1,MAX}
PC: 2 ist: 94000000 ) GROUP_END #:0 { 1, 1}
PC: 3 ist: 7fffffff [-] query_ch { 1, 1}
PC: 4 ist: 92000000 ( GROUP_START #:1 { 1, 1}
PC: 5 ist: 90000000 [\d] BSLS { 1,MAX}
PC: 6 ist: 94000000 ) GROUP_END #:1 { 1, 1}
PC: 7 ist: 7fffffff [ ] query_ch { 1, 1}
PC: 8 ist: 92000000 ( GROUP_START #:2 { 1, 1}
PC: 9 ist: d0000000 [a-z] CHAR_CLASS_POS { 1, 1}
PC: 10 ist: 94000000 ) GROUP_END #:2 { 1, 1}
PC: 11 ist: 7fffffff [:] query_ch { 1, 1}
PC: 12 ist: 7fffffff [ ] query_ch { 1, 1}
PC: 13 ist: 92000000 ( GROUP_START #:3 { 1, 1}
PC: 14 ist: 98000000 . DOT_CHAR { 0,MAX}
PC: 15 ist: 94000000 ) GROUP_END #:3 { 1, 1}
PC: 16 ist: 88000000 PROG_END { 0, 0}
========================================
#0(\d+)-#1(\d+) #2([a-z]): #3(.*)$
flags: 00000004
When trying to find a workaround, I found another test case that fails:
diff --git a/vlib/regex/regex_test.v b/vlib/regex/regex_test.v
index aa5d334b..5e34d583 100644
--- a/vlib/regex/regex_test.v
+++ b/vlib/regex/regex_test.v
@@ -202,6 +202,12 @@ cgroups_test_suite = [
[0, 3, 4, 5, 5, 7],
map[string]int{}
},
+ TestItemCGroup{
+ "8-11 l: qllllqllklhlvtl",
+ r"^(\d+)-(\d+) ([a-z]): (\S+)$",0,23,
+ [0, 1, 2, 4, 5, 6, 8, 23],
+ map[string]int{}
+ },
]
)
@gmlewis Thanks for the segnalation :+1: I made a PR with a possible fix and added your test case to the tests.
Thank you, @penguindark !
@penguindark - I'm trying to update and try out your fix... but I'm having problems... am I doing something wrong?
glenn@glenn-OMEN-875 ~/src/github.com/vlang/v (master) $ make clean
rm -rf ./thirdparty/tcc
rm -rf ./vc
glenn@glenn-OMEN-875 ~/src/github.com/vlang/v (master) $ git pull
Already up to date.
glenn@glenn-OMEN-875 ~/src/github.com/vlang/v (master) $ make
make fresh_vc
make[1]: Entering directory '/home/glenn/src/github.com/vlang/v'
git clone --depth 1 --quiet --single-branch https://github.com/vlang/vc ./vc
make[1]: Leaving directory '/home/glenn/src/github.com/vlang/v'
cd ./vc && git clean -xf && git pull --quiet
make fresh_tcc
make[1]: Entering directory '/home/glenn/src/github.com/vlang/v'
rm -rf ./thirdparty/tcc
git clone --depth 1 --quiet --single-branch --branch thirdparty-linux-amd64 https://github.com/vlang/tccbin ./thirdparty/tcc
make[1]: Leaving directory '/home/glenn/src/github.com/vlang/v'
cd ./thirdparty/tcc && git clean -xf && git pull --quiet
cc -g -std=gnu99 -w -o ./v ./vc/v.c -lm -lpthread
./v self
Segmentation fault (core dumped)
Makefile:62: recipe for target 'all' failed
make: *** [all] Error 139
try to use v up or a clean install.
Anyway you can ask help in the discord #help channel :)
https://discord.com/channels/592103645835821068/592294828432424960
Most helpful comment
@gmlewis Thanks for the segnalation :+1: I made a PR with a possible fix and added your test case to the tests.