Ticket #163: infer-matchCollection-item.patch
File infer-matchCollection-item.patch, 2.8 KB (added by hopscc, 15 years ago) |
---|
-
Source/Boxes.cobra
526 526 if rt.isDescendantOf(.compiler.dictEnumeratorType) 527 527 return rt.memberForName('entry').resultType 528 528 if rt.isDescendantOf(.compiler.enumeratorType) 529 return rt.memberForName('current').resultType 529 rtc = rt.memberForName('current').resultType 530 if rtc.nonNil.name == 'Object' 531 # Can we do better with indexer returnType? (e.g MatchCollection) 532 idxr = .symbolForName(r'[]', true) 533 if idxr 534 rti = idxr.resultType 535 if rti.nonNil.name <> 'Object' 536 return rti 537 return rtc 530 538 else 531 539 throw FallThroughException({'rt': rt, 'this': this, 'getEnum': getEnum}) 532 540 return nil -
Tests/300-type-inference/470-from-matchCollection.cobra
1 # test fix for Ticket 163 - failure infer returntype of re.matches, items of a MatchCollection 2 use System.Text.RegularExpressions 3 4 class TestReMatch 5 6 def main is shared 7 str = '@param folly' # some string 8 rePtn = r'^\s*@param\s+(.*)$' 9 m = Regex.match(str, rePtn) 10 if m.success 11 assert m.captures[0].value == str 12 #print 'Success: capture=[m.groups[1].captures[0]]' 13 assert m.groups[1].captures[0].value == 'folly' 14 15 str = '@param polly\n@param wally\n@param doodle alladay' # some string 16 17 expectCaptures = ['polly', 'wally', 'doodle alladay'] 18 groupsZero = System.Collections.ArrayList(str.split(c'\n')) 19 20 # This only used to compile if explicitly type var as below 21 #for match as Match in Regex.matches(str, rePtn, RegexOptions.Multiline) 22 23 for match in Regex.matches(str, rePtn, RegexOptions.Multiline) 24 assert match.groups[1].captures[0].value == expectCaptures[0] 25 gl = [groupsZero[0], expectCaptures[0]] 26 for g in match.groups 27 #print g.value 28 assert g.value == gl[0] # also wuz fail here 29 gl.removeAt(0) 30 groupsZero.removeAt(0) 31 expectCaptures.removeAt(0) -
Developer/IntermediateReleaseNotes.text
455 455 * Fixed: Missing error checks for `out` and `inout` being used on an indexer or property. 456 456 457 457 * Fixed: `someEnum is nil` causes a run-time exception. 458 459 * Fixed: Failure to infer types related to System.Text.RegularExpressions (MatchColection and GroupCollections items): ticket 163