Changeset 1603

Show
Ignore:
Timestamp:
08/28/08 07:30:27 (3 months ago)
Author:
Chuck.Esterbrook
Message:

Fix a bug in extended initializers regarding passing nil where a strongly typed argument is expected.

Location:
cobra/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • cobra/trunk/Source/Expr.cobra

    r1599 r1603  
    14911491                                arg = arg.right 
    14921492                        else 
    1493                                 argsForInitCall.add(IdentifierExpr(token.copy('ID', 'arg[i]'))) 
     1493                                argsForInitCall.add(if(arg inherits NilLiteral, arg, IdentifierExpr(token.copy('ID', 'arg[i]')))) 
    14941494                        paramsForDecl.add(Param(box.token.copy('ID', 'arg[i]'), arg.type)) 
    14951495                        i += 1 
  • cobra/trunk/Tests/120-classes/320-construct-prop-set.cobra

    r1601 r1603  
    1919                assert s.b == 'b' 
    2020 
     21                t = Thing(nil, data=5)  # test passing nil to a strongly typed arg 
     22                assert t.data == 5 
     23 
     24 
    2125class Stuff 
    2226 
     
    3337         
    3438        pro b from var 
     39 
     40 
     41class Thing 
     42 
     43        var _data as dynamic? 
     44 
     45        def init(s as Stuff?) 
     46                pass 
     47 
     48        pro data from var