Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-1200

JS compiler generates code that clobbers existing namespaces

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.6.1
    • 0.7
    • JavaScript - Compiler
    • None
    • all

    • Patch Available

    Description

      The JavaScript compiler currently generates code that will clobber an already-existing namespace. It should check if the namespace exists before initializing it to {}. Example code pre-patch, assuming the .thrift file has the declaration namespace js CompanyName.ModuleName:

      var CompanyName = {};
      CompanyName.ModuleName = {}
      

      Becomes this after patch:

      if (typeof CompanyName === 'undefined') CompanyName = {};
      if (typeof CompanyName.ModuleName === 'undefined') CompanyName.ModuleName = {};
      

      Attachments

        1. THRIFT-1200-js-namespace-fix.txt
          0.9 kB
          Ilya Maykov

        Activity

          People

            ilyam Ilya Maykov
            ilyam Ilya Maykov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: