@@ -229,7 +229,7 @@ const BUILTIN_MAPPINGS: &[((&str, &str), &str)] = &[
229229 ( ( "_global.search._types" , "TrackHits" ) , "boolean|long" ) ,
230230] ;
231231
232- fn is_list_enum ( union : & UnionOf ) -> bool {
232+ fn is_list_enum ( union : & UnionOf ) -> Option < String > {
233233 // if union of X and X[]
234234 if union. items . len ( ) == 2 {
235235 // check if first item is InstanceOf and second is ArrayOf
@@ -240,12 +240,15 @@ fn is_list_enum(union: &UnionOf) -> bool {
240240 _ => panic ! ( "Expected InstanceOf inside ArrayOf in union type" ) ,
241241 } ;
242242 if instance. typ . name == array_instance. typ . name {
243- return true ;
243+ if instance. typ . name == "string" {
244+ return Some ( "string" . to_string ( ) ) ;
245+ }
246+ return Some ( "enum" . to_string ( ) ) ;
244247 }
245248 }
246249 }
247250 }
248- return false ;
251+ return None ;
249252}
250253
251254fn is_literal ( instance : & InstanceOf ) -> Option < String > {
@@ -261,7 +264,7 @@ fn is_literal(instance: &InstanceOf) -> Option<String> {
261264fn get_type_name ( value_of : & ValueOf , types : & IndexMap < TypeName , TypeDefinition > ) -> String {
262265 match value_of {
263266 ValueOf :: ArrayOf ( _) => "list" . to_string ( ) ,
264- ValueOf :: UnionOf ( union) => if is_list_enum ( union) { "enum" } else { tracing:: warn!( "{:?}" , union ) ; todo ! ( ) } . to_string ( ) ,
267+ ValueOf :: UnionOf ( union) => if let Some ( union_type ) = is_list_enum ( union) { union_type } else { tracing:: warn!( "{:?}" , union ) ; todo ! ( ) } . to_string ( ) ,
265268 ValueOf :: LiteralValue ( _) => "string" . to_string ( ) ,
266269 ValueOf :: InstanceOf ( instance) => {
267270 let type_name = & instance. typ ;
@@ -277,7 +280,7 @@ fn get_type_name(value_of: &ValueOf, types: &IndexMap<TypeName, TypeDefinition>)
277280 match full_type {
278281 TypeDefinition :: TypeAlias ( ref alias) => match & alias. typ {
279282 ValueOf :: UnionOf ( ref union) => {
280- if is_list_enum ( union) {
283+ if let Some ( _ ) = is_list_enum ( union) {
281284 return "list" . to_string ( ) ;
282285 }
283286 }
0 commit comments