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

Can not build Go code when using typedef in IDL

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.9.2
    • None
    • Go - Compiler
    • None

    Description

      // Base.thrift
      namespace go a.X.c
      struct Foo {
          1: required string s
      }
      

      and the dependent file

      // Child.thrift
      namespace go a.Y.c
      include "Base.thrift"
      
      typedef Base.Foo Foo // <---- This is what causes the problem
      
      struct Bar {
          1:Foo f  // <-- Will error
          // 1:Base.Foo f   Need to comment out typedef and use this instead
      }
      

      Compiling the thrift as is works, but when you go to install the a.Y.c package will produce:

      /scratch/go/src/a/Y/c/ttypes.go:78: cannot use c.Foo literal (type *c.Foo) as type *Foo in assignment
      /scratch/go/src/a/Y/c/ttypes.go:79: p.F.Read undefined (type *Foo has no field or method Read)
      /scratch/go/src/a/Y/c/ttypes.go:105: p.F.Write undefined (type *Foo has no field or method Write)
      

      If I comment out the typedef and swap the lines in Bar then everything works fine. This appears to only happen in Go.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              JBruner Joe Bruner
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2h 20m
                  2h 20m