From f03ba40d50b7c03b28f2494e4512348afad12cce Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 7 Jul 2020 18:21:59 +0200 Subject: [PATCH] Fix spurious test failures The accepted child element types are stored in a hash map, so sort them as part of the error message. --- sixtyfps_compiler/tests/basic/path.60 | 2 +- sixtyfps_compiler/typeregister.rs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sixtyfps_compiler/tests/basic/path.60 b/sixtyfps_compiler/tests/basic/path.60 index c811e5e62..4e4433e6a 100644 --- a/sixtyfps_compiler/tests/basic/path.60 +++ b/sixtyfps_compiler/tests/basic/path.60 @@ -6,7 +6,7 @@ TestCase := Rectangle { LineTo { x: 100; y: 0; } LineTo { x: 100; y: 0; } Rectangle {} -// ^error{Rectangle is not allowed within Path. Only LineTo ArcTo are valid children} +// ^error{Rectangle is not allowed within Path. Only ArcTo LineTo are valid children} } LineTo { x: 100; y: 0; } diff --git a/sixtyfps_compiler/typeregister.rs b/sixtyfps_compiler/typeregister.rs index 1cba88ac4..44fc475cd 100644 --- a/sixtyfps_compiler/typeregister.rs +++ b/sixtyfps_compiler/typeregister.rs @@ -117,14 +117,15 @@ impl Type { return Ok(child_type.clone()); } if builtin.disallow_global_types_as_child_elements { + let mut valid_children: Vec<_> = + builtin.additional_accepted_child_types.keys().cloned().collect(); + valid_children.sort(); + return Err(format!( "{} is not allowed within {}. Only {} are valid children", name, builtin.class_name, - builtin - .additional_accepted_child_types - .keys() - .fold(String::new(), |children, ty| children + ty + " ") + valid_children.join(" ") )); } }