[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-smalltalk] [bug] (a RegexResults) at: n throws error if captured a
From: |
sergio |
Subject: |
[Help-smalltalk] [bug] (a RegexResults) at: n throws error if captured at n is empty string |
Date: |
Fri, 06 Dec 2013 15:47:24 -0700 |
Issue status update for
http://smalltalk.gnu.org/node/835
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/835
Project: GNU Smalltalk
Version: <none>
Component: Base classes
Category: bug reports
Priority: normal
Assigned to: Unassigned
Reported by: sergio
Updated by: sergio
Status: active
Small code will be best description:
* !/usr/local/bin/gst -f
data := 'word1 "" word3'.
" next regex catches whatever is between quotes;
when there is something it works; when there is not - later
attempt to access matches at: 2 throws "
(data =~ '(\w+) "([^"]*)" (\w+)')
ifMatched: [ :matches |
| w2 mm |
Transcript
show: 'Matches size is: ', matches size asString ;
nl ;
flush.
" w2 := matches at: 2. // will throw "
" mm := matches asArray. // will throw as it internally calls at:
"
" next cycle will throw on 2nd iteration: "
1 to: matches size do: [ :n |
Transcript show: 'Matches at: ' , n asString , ' is: ['
, (matches at: n) , ']' ; nl ; flush ] ].
Output is:
$ ./test1
Matches size is: 3
Matches at: 1 is: [word1]
Object: Interval new "<0x2aaaac9b7870>" error: Invalid index 1: index
out of range
SystemExceptions.IndexOutOfRange(Exception)>>signal (ExcHandling.st:254)
SystemExceptions.IndexOutOfRange class>>signalOn:withIndex:
(SysExcept.st:660)
Interval>>first (Interval.st:245)
Kernel.MatchingRegexResults>>at: (Regex.st:382)
optimized [] in UndefinedObject>>executeStatements (test1:21)
Kernel.MatchingRegexResults>>ifNotMatched:ifMatched: (Regex.st:322)
Kernel.MatchingRegexResults(RegexResults)>>ifMatched: (Regex.st:188)
UndefinedObject>>executeStatements (test1:7)
I believe it is regress, it worked for me in gst that was... some years
ago, perhaps in Debian 6. I can not say what version it was.