Skip to content

Commit

Permalink
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/string/element_reference_tags.txt
Original file line number Diff line number Diff line change
@@ -7,12 +7,9 @@ fails:String#[] with Range always taints resulting strings when self is tainted
fails:String#[] with Range returns subclass instances
fails:String#[] with Range calls to_int on range arguments
fails:String#[] with Range works with Range subclasses
fails:String#[] with Regexp returns the matching portion of self
fails:String#[] with Regexp returns nil if there is no match
fails:String#[] with Regexp always taints resulting strings when self or regexp is tainted
fails:String#[] with Regexp returns an untrusted string if the regexp is untrusted
fails:String#[] with Regexp returns subclass instances
fails:String#[] with Regexp sets $~ to MatchData when there is a match and nil when there's none
fails:String#[] with Regexp, index returns the capture for the given index
fails:String#[] with Regexp, index always taints resulting strings when self or regexp is tainted
fails:String#[] with Regexp, index returns an untrusted string if the regexp is untrusted
Original file line number Diff line number Diff line change
@@ -313,6 +313,19 @@ public Object slice(RubyString string, int start, int length) {
}
}

@Specialization
public Object slice(RubyString string, RubyRegexp regexp, UndefinedPlaceholder capture) {
notDesignedForCompilation();

final Object matchData = regexp.matchCommon(string.getBytes(), false, false);

if (matchData == getContext().getCoreLibrary().getNilObject()) {
return matchData;
}

return ((RubyMatchData) matchData).getValues()[0];
}

}

@CoreMethod(names = "[]=", required = 2, lowerFixnumParameters = 0)

0 comments on commit b40c330

Please sign in to comment.