Skip to content
This repository has been archived by the owner on Sep 1, 2023. It is now read-only.

Commit

Permalink
Silently ignore missing keys
Browse files Browse the repository at this point in the history
A recent change in HH\facts_parse() made it no longer return empty vecs
for entities kinds that are not declared in the file.
So files without constants do not return `"constants" => vec[]` anymore.
Supply a default value of `vec[]` to match the old behavior and fix CI.
  • Loading branch information
lexidor authored and Atry committed May 30, 2022
1 parent 0e405d8 commit 178ad28
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions bin/hh-autoload.hack
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ final class GenerateScript {
continue;
}
$file_facts = $file_facts as dynamic;
foreach ($file_facts['types'] as $type) {
foreach ($file_facts['types'] ?? vec[] as $type) {
$map['class'][\strtolower($type['name'] as string)] = $path;
}
foreach ($file_facts['constants'] as $const) {
foreach ($file_facts['constants'] ?? vec[] as $const) {
$map['constant'][$const as string] = $path;
}
foreach ($file_facts['functions'] as $fun) {
foreach ($file_facts['functions'] ?? vec[] as $fun) {
$map['function'][\strtolower($fun as string)] = $path;
}
foreach ($file_facts['typeAliases'] as $type) {
foreach ($file_facts['typeAliases'] ?? vec[] as $type) {
$map['type'][\strtolower($type as string)] = $path;
}
}
Expand Down Expand Up @@ -152,8 +152,8 @@ final class GenerateScript {
? $config['devFailureHandler']
: $config['failureHandler'];

$emit_facts_forwarder_file = $config['useFactsIfAvailable'] &&
!$options['no-facts'];
$emit_facts_forwarder_file =
$config['useFactsIfAvailable'] && !$options['no-facts'];

(new Writer())
->setBuilder($importer)
Expand Down
2 changes: 1 addition & 1 deletion src/TypeAssert.hack
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function is_array_of_shapes_with_name_field(
mixed $value,
string $field,
): varray<shape('name' => string)> {
$msg = $field.'should be an array<shape(\'name\' => string)>';
$msg = $field.'should be an vec<shape(\'name\' => string)>';
invariant($value is Traversable<_>, '%s', $msg);
$out = varray[];
foreach ($value as $it) {
Expand Down
8 changes: 4 additions & 4 deletions src/builders/FactParseScanner.hack
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ final class FactParseScanner implements Builder {
try {
$out[$file] = shape(
'types' => TypeAssert\is_array_of_shapes_with_name_field(
$facts['types'] ?? null,
$facts['types'] ?? vec[],
'FactParse types',
),
'constants' => TypeAssert\is_array_of_strings(
$facts['constants'] ?? null,
$facts['constants'] ?? vec[],
'FactParse constants',
),
'functions' => TypeAssert\is_array_of_strings(
$facts['functions'] ?? null,
$facts['functions'] ?? vec[],
'FactParse functions',
),
'typeAliases' => TypeAssert\is_array_of_strings(
$facts['typeAliases'] ?? null,
$facts['typeAliases'] ?? vec[],
'FactParse typeAliases',
),
);
Expand Down

0 comments on commit 178ad28

Please sign in to comment.