minor improvements

This commit is contained in:
Anton-4 2024-12-04 14:32:38 +01:00
parent a2083cec30
commit 7c1dffb777
No known key found for this signature in database
GPG key ID: 0971D718C0A9B937
5 changed files with 11 additions and 9 deletions

View file

@ -446,7 +446,7 @@ fn chomp_opaque_ref(buffer: &[u8], pos: Position) -> Result<&str, BadIdent> {
} else {
let value = unsafe { std::str::from_utf8_unchecked(&buffer[..width]) };
if value.contains('_') {
// we don't allow underscores in the middle of an identifier
// we don't allow underscores in the middle of a type identifier
// but still parse them (and generate a malformed identifier)
// to give good error messages for this case
Err(BadIdent::UnderscoreInMiddle(pos.bump_column(width as u32)))
@ -583,7 +583,7 @@ fn chomp_identifier_chain<'a>(
// just one segment, starting with an uppercase letter; that's a tag
let value = unsafe { std::str::from_utf8_unchecked(&buffer[..chomped]) };
if value.contains('_') {
// we don't allow underscores in the middle of an identifier
// we don't allow underscores in the middle of a tag identifier
// but still parse them (and generate a malformed identifier)
// to give good error messages for this case
Err((
@ -769,10 +769,10 @@ mod tests {
let arena = Bump::new();
assert_ident_parses_simple_access(&arena, "hello_world");
assert_ident_parses_simple_access(&arena, "hello_world23");
assert_ident_parses_simple_access(&arena, "hello_world_this_is_quite_a_tag");
assert_ident_parses_simple_access(&arena, "hello_world_this_is_quite_a_tag_");
assert_ident_parses_simple_access(&arena, "hello_world_this_is_quite_a_tag23");
assert_ident_parses_simple_access(&arena, "hello_world_this_is_quite_a_tag23_");
assert_ident_parses_simple_access(&arena, "hello_world_this_is_quite_a_var");
assert_ident_parses_simple_access(&arena, "hello_world_this_is_quite_a_var_");
assert_ident_parses_simple_access(&arena, "hello_world_this_is_quite_a_var23");
assert_ident_parses_simple_access(&arena, "hello_world_this_is_quite_a_var23_");
}
#[test]