Changeset 1710

Show
Ignore:
Timestamp:
10/27/08 22:45:57 (2 months ago)
Author:
Chuck.Esterbrook
Message:

Fixed: A for statement iterating over a Hashtable doesn't infer the enumerator type correctly (DictionaryEntry?).
ticket:54
credit:hopscc

Location:
cobra/trunk
Files:
1 added
4 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/Developer/IntermediateReleaseNotes.text

    r1704 r1710  
    176176 
    177177* 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 doesn't infer the enumerator type correctly (DictionaryEntry). ticket:54 
  • cobra/trunk/Source/Boxes.cobra

    r1709 r1710  
    438438                                return rt 
    439439                        else 
     440                                if rt.isDescendantOf(.compiler.dictEnumeratorType) 
     441                                        return rt.memberForName('entry').resultType 
    440442                                if rt.isDescendantOf(.compiler.enumeratorType) 
    441443                                        return rt.memberForName('current').resultType 
  • cobra/trunk/Source/Compiler.cobra

    r1704 r1710  
    12281228                return _libraryBox('System.Collections.Generic.IEnumerator<of>') 
    12291229 
     1230        def dictEnumeratorType as Box 
     1231                return _libraryBox('System.Collections.IDictionaryEnumerator') 
     1232                 
    12301233        def collectionType as Box 
    12311234                return _libraryBox('System.Collections.ICollection') 
  • cobra/trunk/Tests/320-misc-two/810-multi-assignment/220-multi-arg-for-dict.cobra

    r1705 r1710  
    7777                assert gdict['a'] == 'z' 
    7878                 
    79                 for dev in gdict 
    80                         de = dev to DictionaryEntry # necessary casting 
     79                for de in gdict 
    8180                        k, v = [de.key, de.value] 
    8281                        assert k in ['a', 'b', 'c'] 
    8382                        assert v in ['z', 'y', 'w'] 
    8483                         
    85                 # this not work till HashTable enumerator type inference implemented 
    86 /#              for k, v in gdict 
     84                for k, v in gdict 
    8785                        assert k in ['a', 'b', 'c'] 
    8886                        assert v in ['z', 'y', 'w'] 
    89 #/                       
     87