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

Compiler ignores duplicate typenames

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.10.0
    • Component/s: Compiler (General)
    • Labels:
      None
    • Environment:

      all

    • Patch Info:
      Patch Available

      Description

      The current IDL compiler will compile the following IDL with no warnings or errors:

      test.thrift
      struct A { 1: i16 a }
      struct A { 1: i16 a }
      

      and this (w/ thrift -r):

      test2.thrift
      include "test.thrift"
      struct A { 1: i16 a }
      

      Both of these IDLs generate un-compilable output in most languages.

      The attached patch adds typename collision checking to the compiler. It generates errors when a typename is declared twice in the same file or when the same typename is declared in two files causing collisions in all namespace scopes. Explicit namespace declarations with collisions in some but not all scopes are reported as warning because the user could compile for a scope that would succeed. More details in the patch comments.

      Built and tested on Windows with VS2012 and Unbuntu w/ gcc 4.7.2
      make check ran on Unbuntu clean (though I had to switch the config.h to thrift/thrift-config.h in TFileTransportTest.cpp)

        Attachments

          Activity

            People

            • Assignee:
              codesf Randy Abernethy
              Reporter:
              codesf Randy Abernethy
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Due:
                Created:
                Updated:
                Resolved: