diff --git a/third-party/thrift/src/thrift/compiler/generate/t_hack_generator.cc b/third-party/thrift/src/thrift/compiler/generate/t_hack_generator.cc index 60b924f0cce21..2bd24abd791c7 100644 --- a/third-party/thrift/src/thrift/compiler/generate/t_hack_generator.cc +++ b/third-party/thrift/src/thrift/compiler/generate/t_hack_generator.cc @@ -116,7 +116,7 @@ class t_hack_generator : public t_concat_generator { json_ = option_is_specified(options, "json"); phps_ = option_is_specified(options, "server"); strict_types_ = option_is_specified(options, "stricttypes"); - arraysets_ = option_is_specified(options, "arraysets"); + auto explicit_arraysets = option_is_specified(options, "arraysets"); no_nullables_ = option_is_specified(options, "nonullables"); from_map_construct_ = option_is_specified(options, "frommap_construct"); shapes_ = option_is_specified(options, "shapes"); @@ -144,16 +144,21 @@ class t_hack_generator : public t_concat_generator { ns_type_ == HackThriftNamespaceType::PACKAGE; has_nested_ns = false; + if (legacy_arrays_ && explicit_arraysets) { + throw std::runtime_error( + "Don't use arraysets with legacy_arrays, because legacy_arrays implies arraysets."); + } + arraysets_ = explicit_arraysets || legacy_arrays_; + if (const_collections_ && explicit_hack_collections) { throw std::runtime_error( "Don't use hack_collections with const_collections, because const_collections implies hack_collections."); } hack_collections_ = explicit_hack_collections || const_collections_; + // legacy_arrays_ is only used to migrate away from php gen if (legacy_arrays_ && strict_types_) { throw std::runtime_error("Don't use legacy_arrays with strict_types"); - } else if (legacy_arrays_ && !arraysets_) { - throw std::runtime_error("Don't use legacy_arrays without arraysets"); } else if (arraysets_ && !(legacy_arrays_ || hack_collections_)) { throw std::runtime_error( "Don't use arraysets without either legacy_arrays or hack_collections"); diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/php-migration/cmd b/third-party/thrift/src/thrift/compiler/test/fixtures/php-migration/cmd index 0b47735e356e7..b08bc9fd40291 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/php-migration/cmd +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/php-migration/cmd @@ -1 +1 @@ -hack: hack:array_migration=1,arraysets=1,frommap_construct=1,legacy_arrays=1,nullable_everything=1,server=1 src/module.thrift +hack: hack:array_migration=1,frommap_construct=1,legacy_arrays=1,nullable_everything=1,server=1 src/module.thrift diff --git a/third-party/thrift/src/thrift/compiler/test/fixtures/shape_construct_no_use_hack_collections/cmd b/third-party/thrift/src/thrift/compiler/test/fixtures/shape_construct_no_use_hack_collections/cmd index 156801d3f4adb..bce409889cf42 100644 --- a/third-party/thrift/src/thrift/compiler/test/fixtures/shape_construct_no_use_hack_collections/cmd +++ b/third-party/thrift/src/thrift/compiler/test/fixtures/shape_construct_no_use_hack_collections/cmd @@ -1 +1 @@ -hack: hack:shape_construct=1,arraysets=1,shapes=1,legacy_arrays=1,shapes_use_pipe_structure=1 src/module.thrift +hack: hack:shape_construct=1,shapes=1,legacy_arrays=1,shapes_use_pipe_structure=1 src/module.thrift