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

default value fails if identifier is a struct

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.4
    • 0.9.1
    • Compiler (General)
    • None

    Description

      The thrift IDL specifies that a field can be a assigned a default ConstValue, which can be an identifier, possibly a struct. However, the compiler rejects this input with the error: type error: const was declared as struct/xception.

      For this example input:

      struct A {
        1: string name = ""
      } 
      const A DEFAULT_A = {}
      struct B {
        1: A a = DEFAULT_A
      } 
      

      The expected output would be something like (in Java):

      public class B {
        public B() {
          this.a = new A(Constants.DEFAULT_A);
        }
      }
      

      Note that a copy of DEFAULT_A is used instead of the DEFAULT_A instance itself.

      Attachments

        Activity

          People

            Unassigned Unassigned
            stephenh Stephen Haberman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: