Boo
  1. Boo
  2. BOO-258

check variable access and privileges at compile time

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.6
    • Component/s: Compiler
    • Labels:
      None
    • Number of attachments :
      0

      Description

      class A:
      private privatefield = 1
      protected protectedfield = 2
      public final publicfinalfield as int = 3

      a = A()
      //these should throw an error at compile time:
      //print a.privatefield
      //print a.protectedfield

      //modifying a final field
      print a.publicfinalfield
      a.publicfinalfield += 1 //no error modifying final field
      print a.publicfinalfield
      a.publicfinalfield += 1 //no error modifying final field
      print a.publicfinalfield

      I'll look into creating more test cases later.

        Activity

        Hide
        Ayende Rahien added a comment -

        It doesn't work on set properties (but works on get properties).
        >>> class M:
        ... private Prop:
        ... set:
        ... pass
        ...
        >>> m().Prop = null
        ----^
        ERROR: Unknown identifier: 'm'.
        >>> M().Prop = null
        System.MethodAccessException: M.set_Prop(System.Object)
        at Input3Module.Main(String[] argv)

        Show
        Ayende Rahien added a comment - It doesn't work on set properties (but works on get properties). >>> class M: ... private Prop: ... set: ... pass ... >>> m().Prop = null ----^ ERROR: Unknown identifier: 'm'. >>> M().Prop = null System.MethodAccessException: M.set_Prop(System.Object) at Input3Module.Main(String[] argv)
        Hide
        Doug H added a comment -

        Also constructors:

        class C:
        private def constructor():
        print "no!"

        c = C()
        print c

        gives a methodaccessexception at runtime

        Show
        Doug H added a comment - Also constructors: class C: private def constructor(): print "no!" c = C() print c gives a methodaccessexception at runtime

          People

          • Assignee:
            Rodrigo B. de Oliveira
            Reporter:
            Doug H
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: