You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
String substringFrom carefully checks bounds and throws an error if they're invalid. However, other functions in String.som call primSubstringFrom directly and sometimes seem to pass start==0, end==0, and end<start. What should primSubstringFrom do in such cases? Throw an error? Return the empty string? Or ... ?
The text was updated successfully, but these errors were encountered:
On my phone.
First though: this sounds like a bug in the using functions and should be fixed there. You got perhaps a test?
Second thought: I never liked this primSubstring thing. It's one of those Smalltalk-isms that break easily because we don't have private methods.
I think the primitive should do what the method does. And be renamed. To replace the method.
Drawback of this is that we can't look at the Smalltalk to see what happens on error
OK, so the bug is that String split: borks if you pass it a string starting with the split string. e.g. '/a/b' split: '/' leads to an index exception in primSubstringFrom. [I found this because I was using absolute paths to pass to SomSom!]
[There may be other methods that call primSubstringFrom incorrectly, but this was the one I've found so far. Looking at som-java, it just throws a Java out of bounds exception in such cases. I should probably convert that into a yksom exception.]
String substringFrom
carefully checks bounds and throws an error if they're invalid. However, other functions inString.som
callprimSubstringFrom
directly and sometimes seem to passstart==0
,end==0
, andend<start
. What shouldprimSubstringFrom
do in such cases? Throw an error? Return the empty string? Or ... ?The text was updated successfully, but these errors were encountered: