mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 20:28:02 +00:00
minor improvements
This commit is contained in:
parent
a2083cec30
commit
7c1dffb777
5 changed files with 11 additions and 9 deletions
|
@ -348,7 +348,7 @@ pub fn build_app() -> Command {
|
|||
.arg(
|
||||
Arg::new(FLAG_MIGRATE)
|
||||
.long(FLAG_MIGRATE)
|
||||
.help("Will fixup syntax to match the latest preferred style. This can cause changes to variable names and more.")
|
||||
.help("Will change syntax to match the latest preferred style. This can cause changes to variable names and more.")
|
||||
.action(ArgAction::SetTrue)
|
||||
.required(false),
|
||||
)
|
||||
|
|
|
@ -526,6 +526,8 @@ pub fn pattern_lift_spaces_after<'a, 'b: 'a>(
|
|||
after: lifted.after,
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert camelCase identifier to snake case
|
||||
fn snakify_camel_ident(buf: &mut Buf, string: &str, flags: &MigrationFlags) {
|
||||
let chars: Vec<char> = string.chars().collect();
|
||||
if !flags.snakify || (string.contains('_') && !string.ends_with('_')) {
|
||||
|
|
|
@ -10696,7 +10696,7 @@ All branches in an `if` must have the same type!
|
|||
4│ f__arg = \x, y, z -> x + y + z
|
||||
^^^^^^
|
||||
|
||||
While snake case is allowed here, only a single consecutive underscore
|
||||
Snake case is allowed here, but only a single consecutive underscore
|
||||
should be used.
|
||||
"
|
||||
),
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -1864,7 +1864,7 @@ fn to_bad_ident_pattern_report<'b>(
|
|||
alloc.reflow("I am trying to parse an identifier here:"),
|
||||
alloc.region(lines.convert_region(surroundings), severity),
|
||||
alloc.concat([
|
||||
alloc.reflow(r"While snake case is allowed here, only a single consecutive underscore should be used.")
|
||||
alloc.reflow(r"Snake case is allowed here, but only a single consecutive underscore should be used.")
|
||||
]),
|
||||
])
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue