Skip to content

Cannot use '_1' as a thrift identifier. #162

Open
@janghwan

Description

@janghwan

The native thrift allows underscore in variable name, but scrooge scala generator does not seem to handle it properly.

This thrift definition

struct StringTuple {
  1: string _1,
  2: string _2
}

generates

trait StringTuple
  extends ThriftStruct
  with scala.Product2[String, String]
  with java.io.Serializable
{
  import StringTuple._

  def _1: String
  def _2: String

  def _passthroughFields: immutable$Map[Short, TFieldBlob] = immutable$Map.empty

  def _1 = _1
  def _2 = _2
//...

, which is wrong obviously.
The identifiers need to be escaped as long as it uses scala.Product.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions