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

Thrift compiler will generate wrong code if IDL struct's name is 'a' or 'b'

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 0.14.0
    • C++ - Compiler
    • None

    Description

      test.thrift file is as below:
      struct a

      { 1: string name, 2: double price }

      struct b

      { 1: i8 size, 2: i32 seq }

      struct a1

      { 1: i8 size, 2: i32 seq }

      struct a2

      { 1: i8 size, 2: i32 seq }

      When struct is named as 'a' or 'b' will throw compile errors as below:
      In file included from test_constants.h:10:0,
      from test_constants.cpp:7:
      test_types.h:76:17: error: ‘a’ is not a type
      void swap(a &a, a &b);
      ^
      In file included from test_types.cpp:7:0:
      test_types.h:76:17: error: ‘a’ is not a type
      void swap(a &a, a &b);
      ^
      test_types.cpp:102:17: error: ‘a’ is not a type
      void swap(a &a, a &b) {
      ^
      test_types.cpp: In function ‘void swap(a&, int&)’:
      test_types.cpp:104:18: error: request for member ‘name’ in ‘b’, which is of non-class type ‘int’
      swap(a.name, b.name);
      ^~~~
      test_types.cpp:105:19: error: request for member ‘price’ in ‘b’, which is of non-class type ‘int’
      swap(a.price, b.price);
      ^~~~~
      test_types.cpp:106:21: error: request for member ‘__isset’ in ‘b’, which is of non-class type ‘int’
      swap(a._isset, b._isset);
      ^~~~~~~

      Attachments

        Issue Links

          Activity

            People

              zeshuai007 Zezeng Wang
              zeshuai007 Zezeng Wang
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: