Skip to content
This repository was archived by the owner on Aug 4, 2025. It is now read-only.
This repository was archived by the owner on Aug 4, 2025. It is now read-only.

Support default values for fields #72

Description

@adamconnelly

Thrift allows fields to be initialised with default values, for example:

struct User {
  1: i32 Id
  2: UserType Type = UserType.User
  3: bool IsEnabled = true
}

There are a number of different types of constant values we need to support:

  • Integers (= 123).
  • Doubles (= 1.2 or = 1.2e5).
  • Strings (= "hello").
  • Enum references (= UserType.User).
  • Constant references (= DEFAULT_VALUE).
  • Lists (= [1, 2, 3]).
  • Maps (= { "key": "value", "key2": "value2").

Notes:

  • We can't support constant references until Generate a const #8 is implemented.
  • We'll need to calculate the type of the constant values, and check they match the type of the field they're being assigned to.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions