Wiki

Ticket #100: final-errck.patch

File final-errck.patch, 1.5 KB (added by hopscc, 16 years ago)
  • Source/Members.cobra

     
    111111            base.isUsed = value 
    112112            .resultType.isUsed = true 
    113113 
     114    get isFinal as bool 
     115        return 'final' in _isNames 
     116         
    114117    get englishName as String is abstract 
    115118 
    116119    get defaultAccessLevel as String 
     
    476479    inherits BoxField 
    477480    implements IVar 
    478481    """ 
    479     A BoxVar is a variable or constant declared for a box, whether instance or shared. For example: 
     482    A BoxVar is a variable declared for a box, whether instance or shared. For example: 
    480483        var _x as int is shared 
    481         const PI = 3.14 
     484        var myPI = 3.14 
    482485 
    483486    Classes and structs can have vars, but interfaces cannot. 
    484487    """ 
  • Source/BinaryOpExpr.cobra

     
    191191            if _left inherits NameExpr 
    192192                _trackLocal = _left.definition inherits AbstractLocalVar 
    193193                if _trackLocal, _trackName = _left.namedDefinition.name 
     194        if .curCodeMember and not .curCodeMember inherits Initializer and _left.definition inherits BoxVar and _left.definition.isFinal 
     195            .throwError('The final field "[_left.definition.name]" cannot be assigned to except in an initializer or the fields declaration and initialization') 
     196                         
    194197 
    195198 
    196199class AssignExpr