Wiki

Changeset 1912

Show
Ignore:
Timestamp:
01/17/09 22:55:30 (3 years ago)
Author:
Chuck.Esterbrook
Message:

Fixed: Passing a method reference as a named property to an initalizer causes a false compilation error.
reported-by:jonathandavid

Location:
cobra/trunk
Files:
3 modified

Legend:

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

    r1908 r1912  
    310310 
    311311* Fixed: The compile does not correctly read nilable types from libraries, resulting in false compilation errors. ticket:136 
     312 
     313* Fixed: Passing a method reference as a named property to an initalizer causes a false compilation error. 
  • cobra/trunk/Source/Expr.cobra

    r1900 r1912  
    17061706                propsToSet.add(arg) 
    17071707                if firstPropArg == -1, firstPropArg = i 
     1708                propertyName = (arg.left to IdentifierExpr).name 
     1709                argType = _expr.memberForName(propertyName).resultType 
    17081710                arg = arg.right 
    17091711            else 
    17101712                argsForInitCall.add(if(arg inherits NilLiteral, arg, IdentifierExpr(token.copy('ID', 'arg[i]')))) 
    1711             paramsForDecl.add(Param(box.token.copy('ID', 'arg[i]'), arg.type)) 
     1713                argType = arg.type to ! 
     1714            paramsForDecl.add(Param(box.token.copy('ID', 'arg[i]'), argType)) 
    17121715            i += 1 
    17131716        name = '_ch_ext_init_[.serialNum]'  # ch = class helper, ext = extended, init = initializer 
  • cobra/trunk/Tests/120-classes/320-construct-prop-set.cobra

    r1709 r1912  
    11class X 
    22 
    3     def main is shared 
    4         s = Stuff(a=1, b=2) 
    5         assert s.a == 1 
    6         assert s.b == 2 
     3    shared 
     4     
     5        var _counter = 0 
     6         
     7        get counter from var 
     8     
     9        def incCounter 
     10            _counter += 1 
    711 
    8         s = Stuff('a', b='b') 
    9         assert s.a == 'a' 
    10         assert s.b == 'b' 
    11  
    12         letters = 'aoeu' 
    13         s = Stuff(letters, b='b') 
    14         assert s.a == letters 
    15         assert s.b == 'b' 
    16  
    17         s = Stuff(nil, b='b') 
    18         assert s.a is nil 
    19         assert s.b == 'b' 
    20  
    21         t = Thing(nil, data=5)  # test passing nil to a strongly typed arg 
    22         assert t.data == 5 
    23  
    24         s = Stuff(style=StyleType(Hype))  # test enum construction nested inside a prop set 
     12        def main 
     13            s = Stuff(a=1, b=2) 
     14            assert s.a == 1 
     15            assert s.b == 2 
     16     
     17            s = Stuff('a', b='b') 
     18            assert s.a == 'a' 
     19            assert s.b == 'b' 
     20     
     21            letters = 'aoeu' 
     22            s = Stuff(letters, b='b') 
     23            assert s.a == letters 
     24            assert s.b == 'b' 
     25     
     26            s = Stuff(nil, b='b') 
     27            assert s.a is nil 
     28            assert s.b == 'b' 
     29     
     30            s = Stuff(doSomething = ref .incCounter)  # pass a method reference 
     31            assert .counter == 0 
     32            ds = s.doSomething 
     33            ds() 
     34            assert .counter == 1 
     35             
     36            t = Thing(nil, data=5)  # test passing nil to a strongly typed arg 
     37            assert t.data == 5 
     38     
     39            s = Stuff(style=StyleType(Hype))  # test enum construction nested inside a prop set 
    2540 
    2641 
     
    5065 
    5166 
     67    sig DoSomethingSig 
     68 
     69    pro doSomething from var as DoSomethingSig? 
     70 
     71 
    5272class Thing 
    5373