Skip to content

Commit c33e794

Browse files
committed
Guard against Rat positions in print commands
t/11-golf.t seems to manage to pass a Rat (`T.colums/2`) to `T.print-string`. Unsure why this didn't fail earlier.
1 parent 7cd4b78 commit c33e794

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

lib/Terminal/Print/Commands.pm6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ my %commands =
3030
sub columns is export { Terminal::API::get-window-size().cols }
3131
sub rows is export { Terminal::API::get-window-size().rows }
3232

33-
sub move-cursor(Int $x, Int $y) is export {
33+
sub move-cursor(Int() $x, Int() $y) is export {
3434
"\e[{$y+1};{$x+1}H"
3535
}
3636

lib/Terminal/Print/Grid.pm6

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,21 +240,21 @@ multi method cell(Str $char) {
240240
}
241241

242242
#| Replace the contents of a single grid cell, specifying a hash with char and color keys
243-
multi method change-cell($x, $y, %c) {
243+
multi method change-cell(Int() $x, Int() $y, %c) {
244244
return unless 0 <= $x < $!w && 0 <= $y < $!h;
245245
$!grid-string = '';
246246
@!grid[$y][$x] = Cell.fast-create(%c<char>, %c<color>);
247247
}
248248

249249
#| Replace the contents of a single grid cell with a single uncolored/unstyled character
250-
multi method change-cell($x, $y, Str $char) {
250+
multi method change-cell(Int() $x, Int() $y, Str $char) {
251251
return unless 0 <= $x < $!w && 0 <= $y < $!h;
252252
$!grid-string = '';
253253
@!grid[$y][$x] = $char;
254254
}
255255

256256
#| Replace the contents of a single grid cell with a prebuilt Cell object
257-
multi method change-cell($x, $y, Cell $cell) {
257+
multi method change-cell(Int() $x, Int() $y, Cell $cell) {
258258
return unless 0 <= $x < $!w && 0 <= $y < $!h;
259259
$!grid-string = '';
260260
@!grid[$y][$x] = $cell;

0 commit comments

Comments
 (0)