Skip to content

Commit 67bca89

Browse files
giacomocavalierilpil
authored andcommitted
stop suggesting project names starting with the gleam_ prefix
fixes #4844
1 parent 7ef91ef commit 67bca89

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,7 @@
142142
- Fixed a bug where the compiler would crash if there was an invalid version
143143
requirement in a project's `gleam.toml`.
144144
([Giacomo Cavalieri](https://github.com/giacomocavalieri))
145+
146+
- Fixed a bug where the compiler would suggest a discouraged project name as an
147+
alternative to the reserved `gleam` name.
148+
([Giacomo Cavalieri](https://github.com/giacomocavalieri))

compiler-cli/src/new.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,13 @@ fn suggest_valid_name(invalid_name: &str, reason: &InvalidProjectNameReason) ->
379379
Some(format!("{invalid_name}_app"))
380380
}
381381
InvalidProjectNameReason::GleamReservedWord => Some(format!("{invalid_name}_app")),
382-
InvalidProjectNameReason::GleamReservedModule => Some(format!("{invalid_name}_app")),
382+
InvalidProjectNameReason::GleamReservedModule => {
383+
if invalid_name == "gleam" {
384+
Some("app_gleam".into())
385+
} else {
386+
Some(format!("{invalid_name}_app"))
387+
}
388+
}
383389
InvalidProjectNameReason::FormatNotLowercase => Some(invalid_name.to_lowercase()),
384390
InvalidProjectNameReason::Format => {
385391
let suggestion = regex::Regex::new(r"[^a-z0-9]")

compiler-cli/src/new/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ fn suggest_valid_names() {
412412
"gleam",
413413
&crate::new::InvalidProjectNameReason::GleamReservedModule
414414
),
415-
Some("gleam_app".to_string())
415+
Some("app_gleam".to_string())
416416
);
417417

418418
assert_eq!(

0 commit comments

Comments
 (0)