Skip to content

Commit d3d433c

Browse files
authored
[fix] Emit at_offset for anonymous block args (#944)
* Fixtures * Emit `at_offset` for anonymous block args
1 parent 5e478d5 commit d3d433c

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
11
def foo(a, b, &)
22
bar a, b, &
33
end
4+
5+
def foo(
6+
a,
7+
&
8+
)
9+
bar(
10+
a,
11+
&)
12+
end
13+
14+
def foo(
15+
a,
16+
*b,
17+
&
18+
)
19+
bar(
20+
a,
21+
b,
22+
&
23+
)
24+
end
25+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
11
def foo(a, b, &)
22
bar(a, b, &)
33
end
4+
5+
def foo(
6+
a,
7+
&
8+
)
9+
bar(
10+
a,
11+
&
12+
)
13+
end
14+
15+
def foo(
16+
a,
17+
*b,
18+
&
19+
)
20+
bar(
21+
a,
22+
b,
23+
&
24+
)
25+
end

librubyfmt/src/format_prism.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,8 @@ fn format_block_parameter_node<'src>(
16361636
let ident_str = ident.as_slice();
16371637
ps.bind_variable(ident_str);
16381638
handle_string_at_offset(ps, ident_str, block_arg.name_loc().unwrap().end_offset());
1639+
} else {
1640+
ps.at_offset(block_arg.location().start_offset());
16391641
}
16401642
});
16411643
}

0 commit comments

Comments
 (0)