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

Go: invalid code generated when exception name is a go keyword

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.9.2
    • Go - Compiler
    • All platforms

    • Patch Available

    Description

      Go code generator emits invalid code when a service method is declared to throw an exception, which name is a Go keyword.

      To reproduce, create gobug.thrift:

      gobug.thrift
      exception FooError { }
      
      service Foo {
              void bar() throws (1: FooError error)
      }
      

      Run:

      thrift -gen go gobug.thrift && (cd gen-go/gobug && go build -a)
      

      This should result in the following error:

      ./foo.go:106: result1.Error undefined (type *BarResult has no field or method Error)
      ./foo.go:107: type error is not an expression
      ./foo.go:107: cannot assign to <nil>.error
      ./foo.go:107: result1.Error undefined (type *BarResult has no field or method Error)
      

      Attachments

        1. thrift-go.patch
          1 kB
          Krzysztof Godlewski

        Activity

          People

            jensg Jens Geyer
            kgodlewski Krzysztof Godlewski
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: