Polymorphic JSON for aliased_namespaces ([] or {...})nightly-2020.02.19
commit6065d5491628e7eff88b1a82bf8f53b322d4bfb6
authorLeo Osvald <leoo@fb.com>
Tue, 18 Feb 2020 23:39:08 +0000 (18 15:39 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 18 Feb 2020 23:43:31 +0000 (18 15:43 -0800)
tree5abf385fd0e6d256fe8bf54781f7cb307fc8b366
parentda26390805df732a58294af369486f3ceab572be
Polymorphic JSON for aliased_namespaces ([] or {...})

Summary:
JSON parser in hhbc_options.ml expects `hhvm.aliased_namespaces` to be:
- JSON array (`[]`) if empty
- JSON object (`{}`) in general (non-empty doesn't parse as array!)

Instead of adding complexity by providing custom deserializer visitor
that looks into the JSON value associated with such keys,
and putting the burden of remembering that default SerDe isn't enough
for every potentially new option that is added in the future
(which is exceptionally represented as [] instead of {} when empty),
just introduce the wrapper type and a convenience method `as_map`
that gives back the unwrapped map.

Reviewed By: dabek

Differential Revision: D19954265

fbshipit-source-id: 20d63dc813123523ba4d3a153dff1181335aa77a
hphp/hack/src/hhbc/compile.rs
hphp/hack/src/hhbc/options.rs
hphp/hack/test/rust/hhbc_options_migration_test.ml