update-scripts: Correctly handle propreties without a 'type'

This commit is contained in:
Quentin Boyer 2025-01-17 20:31:58 +01:00
parent 8e9458eacf
commit 674790dbf9

View file

@ -41,7 +41,7 @@ let
let let
inner = inner =
{ {
type, type ? null,
enum ? null, enum ? null,
minimum ? null, minimum ? null,
maximum ? null, maximum ? null,
@ -66,7 +66,10 @@ let
t: mkRustAnalyzerOptionType nullable "${property_name}-sub" t t: mkRustAnalyzerOptionType nullable "${property_name}-sub" t
) possibleTypes; ) possibleTypes;
} }
else if lib.isList type then else
(
assert lib.assertMsg (type != null) "property is neither anyOf nor enum, it must have a type";
if lib.isList type then
( (
if lib.head type == "null" then if lib.head type == "null" then
assert lib.assertMsg ( assert lib.assertMsg (
@ -117,7 +120,8 @@ let
then then
{ kind = type; } { kind = type; }
else else
throw "Unhandled value in ${property_name}: ${lib.generators.toPretty { } property}"; throw "Unhandled value in ${property_name}: ${lib.generators.toPretty { } property}"
);
in in
builtins.addErrorContext "While creating type for ${property_name}:\n${lib.generators.toPretty { } property}" ( builtins.addErrorContext "While creating type for ${property_name}:\n${lib.generators.toPretty { } property}" (
inner property inner property