Ticket #54: infer-hashTable-enumType.patch
File infer-hashTable-enumType.patch, 3.8 KB (added by hopscc, 16 years ago) |
---|
-
Source/Compiler.cobra
1227 1227 def enumeratorOfType as Box 1228 1228 return _libraryBox('System.Collections.Generic.IEnumerator<of>') 1229 1229 1230 def dictEnumeratorType as Box 1231 return _libraryBox('System.Collections.IDictionaryEnumerator') 1232 1230 1233 def collectionType as Box 1231 1234 return _libraryBox('System.Collections.ICollection') 1232 1235 -
Source/Boxes.cobra
437 437 rt = rt.memberForName('current').resultType 438 438 return rt 439 439 else 440 if rt.isDescendantOf(.compiler.dictEnumeratorType) 441 return rt.memberForName('entry').resultType 440 442 if rt.isDescendantOf(.compiler.enumeratorType) 441 443 return rt.memberForName('current').resultType 442 444 else -
Tests/400-misc-bugs/220-infer-hashTable-enumerator.cobra
1 #Test inference of DictionaryEntry from Hashtable enumerator 2 class HTBug 3 def main is shared 4 .testHTEnumerator 5 .testKeyValDecompose 6 7 def testHTEnumerator is shared 8 ht = Hashtable() 9 ht['a'] = 'value1' 10 ht['b'] = 'value2' 11 ht['c'] = 'value3' 12 for de in ht 13 assert de.getType == System.Collections.DictionaryEntry.getType 14 #print de.key, de.value 15 assert de.key in ['a', 'b', 'c'] 16 assert de.value in ['value1', 'value2', 'value3'] 17 18 ht1 = Hashtable() 19 ht1['x'] = 'Xvalue1' 20 ht1['y'] = 'Xvalue2' 21 ht1['z'] = 'Xvalue3' 22 for de1 in ht1 23 assert de1.key in ['x', 'y', 'z'] 24 assert de1.value in ['Xvalue1', 'Xvalue2', 'Xvalue3'] 25 26 for de in ht1 27 assert de.key in ['x', 'y', 'z'] 28 assert de.value in ['Xvalue1', 'Xvalue2', 'Xvalue3'] 29 30 31 def testKeyValDecompose is shared 32 ht=Hashtable() 33 ht['a'] = 'value1' 34 ht['b'] = 'value2' 35 ht['c'] = 'value3' 36 for k,v in ht 37 assert k in ['a', 'b', 'c'] 38 assert v in ['value1', 'value2', 'value3'] -
Tests/320-misc-two/810-multi-assignment/220-multi-arg-for-dict.cobra
76 76 gdict['c'] = 'w' 77 77 assert gdict['a'] == 'z' 78 78 79 for dev in gdict 80 de = dev to DictionaryEntry # necessary casting 79 for de in gdict 81 80 k, v = [de.key, de.value] 82 81 assert k in ['a', 'b', 'c'] 83 82 assert v in ['z', 'y', 'w'] 84 83 85 # this not work till HashTable enumerator type inference implemented 86 /# for k, v in gdict 84 for k, v in gdict 87 85 assert k in ['a', 'b', 'c'] 88 86 assert v in ['z', 'y', 'w'] 89 #/87 -
Developer/IntermediateReleaseNotes.text
175 175 * Fixed: CobraCore.exePath uses `Assembly.getExecutingAssembly` when it should be using `Assembly.getEntryAssembly` instead. This reveals itself when using -embed-run-time:no. 176 176 177 177 * Fixed: Reading enums with non-int32 storage types (such as uint32 and uint64) causes an exception in the compiler. 178 179 * Fixed: A for statement iterating over a Hashtable didnt infer the enumerator type (DictionaryEntry) correctly. ticket:54