···
520
520
writing a constructor with a lowercase name.
521
521
([Giacomo Cavalieri](https://github.com/giacomocavalieri))
522
522
523
523
+
- Fixed a bug where guards with comments wouldn't be formatted properly.
524
524
+
([Giacomo Cavalieri](https://github.com/giacomocavalieri))
525
525
+
523
526
- A `gleam@@compile.erl` is no longer left in the build output of
524
527
`gleam compile-package`.
525
528
([Louis Pilfold](https://github.com/lpil))
···
3093
3093
left: &'a UntypedClauseGuard,
3094
3094
right: &'a UntypedClauseGuard,
3095
3095
) -> Document<'a, 'doc> {
3096
3096
-
self.clause_guard_bin_op_side(arena, name, left, left.precedence())
3097
3097
-
.append(arena, BREAKABLE_SPACE_DOCUMENT)
3098
3098
-
.append(arena, binop(*name))
3099
3099
-
.append(arena, SPACE_DOCUMENT)
3100
3100
-
.append(
3101
3101
-
arena,
3102
3102
-
self.clause_guard_bin_op_side(arena, name, right, right.precedence() - 1),
3103
3103
-
)
3096
3096
+
let left_comments = self.pop_comments(left.location().start);
3097
3097
+
let left = self.clause_guard_bin_op_side(arena, name, left, left.precedence());
3098
3098
+
let left = commented(arena, left, left_comments);
3099
3099
+
3100
3100
+
let right_comments = self.pop_comments(right.location().start);
3101
3101
+
let right = self.clause_guard_bin_op_side(arena, name, right, right.precedence() - 1);
3102
3102
+
let right = docvec![arena, binop(*name), SPACE_DOCUMENT, right];
3103
3103
+
let right = commented(arena, right, right_comments);
3104
3104
+
3105
3105
+
left.append(arena, BREAKABLE_SPACE_DOCUMENT)
3106
3106
+
.append(arena, right)
3104
3107
}
3105
3108
3106
3109
fn clause_guard_bin_op_side(
···
52
52
}
53
53
54
54
#[test]
55
55
+
fn commented_operators_in_guard() {
56
56
+
assert_format!(
57
57
+
r#"pub fn main() {
58
58
+
case list.map(codepoints, string.utf_codepoint_to_int) {
59
59
+
[drive, colon, slash]
60
60
+
if { slash == 47 || slash == 92 }
61
61
+
&& colon == 58
62
62
+
// Hello
63
63
+
&& drive >= 65
64
64
+
&& drive <= 90
65
65
+
// This is a comment
66
66
+
|| drive >= 97
67
67
+
// And another one
68
68
+
&& drive <= 122
69
69
+
-> {
70
70
+
1
71
71
+
|> 2
72
72
+
}
73
73
+
}
74
74
+
}
75
75
+
"#
76
76
+
);
77
77
+
}
78
78
+
79
79
+
#[test]
55
80
fn a_comment_before_a_guard_doesnt_force_it_to_break() {
56
81
assert_format!(
57
82
r#"pub fn main() {