ngs-lang / ngs

Next Generation Shell (NGS)
https://ngs-lang.org/
GNU General Public License v3.0
1.4k stars 43 forks source link

Crash when accessing RegExp#options #536

Closed organom closed 2 years ago

organom commented 2 years ago

Impacts #524

Run docker image:

docker run -it archlinux:base-20220116.0.44468

Inside docker run:

pacman -Sy vi git clang

export CC=clang
export CXX=clang++

git clone https://github.com/ngs-lang/ngs.git
cd ngs 
git checkout 507-improve-gh-actions
./install.sh
make tests
cat /ngs/build/Testing/Temporary/LastTest.log

Started commenting out the tests that were failing (still more failing )

diff --git a/lib/stdlib.ngs b/lib/stdlib.ngs
index f829fbf..fe37df9 100644
--- a/lib/stdlib.ngs
+++ b/lib/stdlib.ngs
@@ -4333,8 +4333,8 @@ section "Strings and characters" {
        doc %RET - Arr of Str
        F words(s:Str) (s ~~ /\S+/m).matches.map(X[0])

-       TEST "ab cd\nef".words() == %[ab cd ef]
-       TEST " x y  ".words() == %[x y]
+       #TEST "ab cd\nef".words() == %[ab cd ef]
+       #TEST " x y  ".words() == %[x y]

        doc Prepend each line in a with s
        doc %EX - "a " + ["1", "2"]  # ["a 1", "a 2"]
@@ -4451,7 +4451,7 @@ section "Strings and characters" {
        doc Replace all occurrences of src with dst in s
        F replace(s:Str, src:Str, dst:Str) (~~)(s, src, true).map(only(MatchSuccess, {dst})).join('')

-       TEST "x10ab20c30y".replace("0", "X") == "x1Xab2Xc3Xy"
+#      TEST "x10ab20c30y".replace("0", "X") == "x1Xab2Xc3Xy"

        doc Convert a Str to NGS code that would produce the string when executed. Not fully functional yet.
        doc BUG: Does not do escaping.
@@ -6819,12 +6819,12 @@ F ~~(s:Str, r:RegExp, collect_unmatched:Bool=false) {

 # TODO: test ~~() \r\n skipping
 # Crashes on Ubuntu 14.04 clang 3.5.0 (Travis CI)
-TEST (try ENV.TRAVIS and ENV.CC == "clang") returns true; ("ab\r\ncd" ~~ /(*CRLF)|./m).whole.filter(len) == ['a', 'b', 'c', 'd']
+#TEST (try ENV.TRAVIS and ENV.CC == "clang") returns true; ("ab\r\ncd" ~~ /(*CRLF)|./m).whole.filter(len) == ['a', 'b', 'c', 'd']
 # Crashes on Ubuntu 14.04 clang 3.5.0 (Travis CI)
-TEST (try ENV.TRAVIS and ENV.CC == "clang") returns true; ("ab\r\ncd" ~~ /|./m).whole.filter(len) == ['a', 'b', '\r', 'c', 'd']
+#TEST (try ENV.TRAVIS and ENV.CC == "clang") returns true; ("ab\r\ncd" ~~ /|./m).whole.filter(len) == ['a', 'b', '\r', 'c', 'd']
 # UTF-8 of "я" is 209(D1), 143(8F)
 # Skip for older library using try ... catch
-TEST try ("aяb" ~~ /(*UTF)|\\x8F|b/).whole.filter(len) == ['b'] catch(e:RegExpCompileFail) 'not recognized' in e.message
+#TEST try ("aяb" ~~ /(*UTF)|\\x8F|b/).whole.filter(len) == ['b'] catch(e:RegExpCompileFail) 'not recognized' in e.message

 # Last two are for repeated searches
 STDLIB_REGEXP_FLAGS = {
@@ -6870,14 +6870,14 @@ doc %EX - "x10ab20c30y".split(/[0-9]+/).join(" :: ")  # "x :: ab :: c :: y"
 F split(s:Str, r:RegExp) (~~)(s, r, true).filter(Str)

 # Crashes on Ubuntu 14.04 clang 3.5.0 (Travis CI)
-TEST (try ENV.TRAVIS and ENV.CC == "clang") returns true; "ab01de12f".split(/[0-9]+/) == ['ab', 'de', 'f']
+#TEST (try ENV.TRAVIS and ENV.CC == "clang") returns true; "ab01de12f".split(/[0-9]+/) == ['ab', 'de', 'f']

 doc Get string with all occurrences of r removed
 doc %RET - Str
 doc %EX - "x10ab20c30y".without(/[0-9]+/)  # "xabcy"
 F without(s:Str, r:RegExp) s.split(r).join('')

-TEST (try ENV.TRAVIS and ENV.CC == "clang") returns true; "ab01de12f".without(/[0-9]+/) == 'abdef'
+#TEST (try ENV.TRAVIS and ENV.CC == "clang") returns true; "ab01de12f".without(/[0-9]+/) == 'abdef'

 # TODO: make it a low priority method implementation
 doc Get substring of a string that corresponds to first match of given regular expression
@@ -6913,11 +6913,11 @@ F replace(s:Str, r:RegExp, mapper:Fun) {
        }).join('')
 }

-TEST "x10ab20c30y".replace(/[0-9]+/, F(match_text) "[$match_text]") == "x[10]ab[20]c[30]y"
+#TEST "x10ab20c30y".replace(/[0-9]+/, F(match_text) "[$match_text]") == "x[10]ab[20]c[30]y"

 F replace(s:Str, r:RegExp, replacement:Str) s.replace(r, {replacement})
ilyash-b commented 2 years ago

In dev and in 507-improve-gh-actions