Wiki

Ticket #75: ticket75.patch

File ticket75.patch, 1.0 KB (added by eric.sellon, 15 years ago)
  • Source/BinaryOpExpr.cobra

     
    224224            if _type is nil 
    225225                _type = .compiler.passThroughType 
    226226            throw 
     227        if _left inherits DotExpr and _left.definition inherits Property and _left.definition.setPart is nil 
     228            .throwError('Cannot assign to property [_left.definition.name] since it is read only.') 
    227229        left = _left 
    228230        right = _right 
    229231        assert right.type 
  • Tests/120-classes/500-properties/320-properties-read-only-assign.cobra

     
     1class X 
     2     
     3    var _bob as String? 
     4     
     5    get two as int 
     6        return 2 
     7 
     8    pro bob from var 
     9     
     10    def main is shared 
     11        x = X() 
     12        x.bob = "hi" 
     13        x.two = 4  # .error. Cannot assign