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

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

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.9.2
    • Component/s: Go - Compiler
    • Labels:
    • Environment:

      All platforms

    • Patch Info:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: