diff --git a/compiler/cpp/src/thrift/generate/t_erl_generator.cc b/compiler/cpp/src/thrift/generate/t_erl_generator.cc index 372c78bf704..9e1e23dacfa 100644 --- a/compiler/cpp/src/thrift/generate/t_erl_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_erl_generator.cc @@ -810,6 +810,8 @@ void t_erl_generator::generate_erl_struct_member(ostream& out, t_field* tmember) if (has_default_value(tmember)) out << " = " << render_member_value(tmember); out << " :: " << render_member_type(tmember); + if (tmember->get_req() != t_field::T_REQUIRED) + out << " | 'undefined'"; } bool t_erl_generator::has_default_value(t_field* field) {