Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-35114

static constants in constructor don't compile correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • Apache FalconJX 0.8.0
    • FalconJX
    • None

    Description

      package
      {
      	public class Dummy
      	{
      		public static const NAME:String = "Dummy";
      		public function Dummy(myName:String=NAME)
      		{
      			_name = myName;
      		}
      		private var _name:String;
      	}
      }
      

      The constructor compiles to this:

      /**
       * @constructor
       * @param {string=} myName
       */
      Dummy = function(myName) {
        myName = typeof myName !== 'undefined' ? myName : NAME;
        this._name = myName;
      };
      
      
      /**
       * @export
       * @const
       * @type {string}
       */
      Dummy.NAME = "Dummy";
      

      When trying to instantiate, you'll get an error NAME is undefined.

      It should be this instead:

        myName = typeof myName !== 'undefined' ? myName : Dummy.NAME;
      

      Attachments

        Activity

          People

            aharui Alex Harui
            harbs Harbs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: