Skip to content

Commit 9d43207

Browse files
Courtcircuitslpil
authored andcommitted
renamed guard_clause in clause_guard and typos
Signed-off-by: Courtcircuits <[email protected]>
1 parent 8f3ed5e commit 9d43207

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

compiler-core/src/parse.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,16 +1625,16 @@ where
16251625
let Some((start, end)) = self.maybe_one(&Token::If) else {
16261626
return Ok(None);
16271627
};
1628-
let guard_clause_result = self.parse_clause_guard_inner();
1629-
// if inner clause is none, a warning should be thrown to prevent that this behaviour
1630-
// is deprecated
1631-
if let Ok(None) = guard_clause_result {
1628+
let clause_guard_result = self.parse_clause_guard_inner();
1629+
// If inner clause is none, a warning should be shown to let the user
1630+
// know that empty clauses in guards are deprecated.
1631+
if let Ok(None) = clause_guard_result {
16321632
self.warnings
1633-
.push(DeprecatedSyntaxWarning::DeprecatedEmptyGuardClause {
1633+
.push(DeprecatedSyntaxWarning::DeprecatedEmptyClauseGuard {
16341634
location: SrcSpan { start, end },
16351635
});
16361636
}
1637-
guard_clause_result
1637+
clause_guard_result
16381638
}
16391639

16401640
fn parse_clause_guard_inner(&mut self) -> Result<Option<UntypedClauseGuard>, ParseError> {

compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__warnings__empty_guard_clause.snap

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ pub fn main() {
1414
}
1515

1616
----- WARNING
17-
warning: Deprecated empty guard clause syntax
17+
warning: Deprecated empty guard syntax
1818
┌─ test/path:5:12
1919
2020
510 if -> True
21-
^^ This should be followed by a guard or removed!!
21+
^^ This can be removed.
2222

23-
24-
Empty clause within a guard is deprecated.
25-
To keep its behaviour, either remove the guard or fill the clause with
26-
`True` instead.
23+
This syntax for an empty guard is deprecated. To have a clause without a
24+
guard, remove this.

compiler-core/src/warning.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ pub enum DeprecatedSyntaxWarning {
246246
/// ```gleam
247247
/// case wibble {
248248
/// big if -> True
249-
/// ^^ this should be followed by a guard or removed!!
249+
/// ^^ This can be removed.
250250
/// }
251251
/// ```
252-
DeprecatedEmptyGuardClause {
252+
DeprecatedEmptyClauseGuard {
253253
location: SrcSpan,
254254
},
255255

@@ -369,19 +369,20 @@ To match on all possible lists, use the `_` catch-all pattern instead.",
369369
Warning::DeprecatedSyntax {
370370
path,
371371
src,
372-
warning: DeprecatedSyntaxWarning::DeprecatedEmptyGuardClause { location },
372+
warning: DeprecatedSyntaxWarning::DeprecatedEmptyClauseGuard { location },
373373
} => Diagnostic {
374-
title: "Deprecated empty guard clause syntax".into(),
374+
title: "Deprecated empty guard syntax".into(),
375375
text: wrap(
376-
"Empty clause within a guard is deprecated.
377-
To keep its behaviour, either remove the guard or fill the clause with `True` instead.",
376+
"This syntax for an empty guard is deprecated. \
377+
To have a clause without a guard, remove this.",
378378
),
379379
hint: None,
380380
level: diagnostic::Level::Warning,
381381
location: Some(Location {
382382
label: diagnostic::Label {
383-
text: Some("This should be followed by a guard or removed!!
384-
".into()),
383+
text: Some(
384+
"This can be removed.".into(),
385+
),
385386
span: *location,
386387
},
387388
path: path.clone(),

0 commit comments

Comments
 (0)