Skip to content

Commit 969677a

Browse files
committed
Add given value to printf bad-directive-type error
1 parent 7ac2d85 commit 969677a

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/HLL/sprintf.nqp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ my module sprintf {
8484
nqp::throw($ex);
8585
}
8686

87-
sub bad-type-for-directive($type, $directive) {
88-
my $message := "Directive $directive not applicable for type " ~ $type.HOW.name($type);
87+
sub bad-type-for-directive($type, $directive, $value) {
88+
my $message := "Directive $directive not applicable for value of type " ~ $type.HOW.name($type) ~ " ($value)";
8989
my $payload := nqp::hash('BAD_TYPE_FOR_DIRECTIVE',
90-
nqp::hash('TYPE', $type.HOW.name($type), 'DIRECTIVE', $directive));
90+
nqp::hash('TYPE', $type.HOW.name($type), 'DIRECTIVE', $directive, 'VALUE', $value));
9191
panic($message, $payload);
9292
}
9393

@@ -178,7 +178,7 @@ my module sprintf {
178178
method directive:sym<b>($/) {
179179
my $next := next_argument($/);
180180
CATCH {
181-
bad-type-for-directive($next, 'b');
181+
bad-type-for-directive($next, 'b', @*ARGS_HAVE);
182182
}
183183
my $int := intify($next);
184184
my $pad := padding_char($/);
@@ -208,15 +208,15 @@ my module sprintf {
208208
method directive:sym<c>($/) {
209209
my $next := next_argument($/);
210210
CATCH {
211-
bad-type-for-directive($next, 'c');
211+
bad-type-for-directive($next, 'c', @*ARGS_HAVE);
212212
}
213213
make nqp::chr(intify($next))
214214
}
215215

216216
method directive:sym<d>($/) {
217217
my $next := next_argument($/);
218218
CATCH {
219-
bad-type-for-directive($next, 'd');
219+
bad-type-for-directive($next, 'd', @*ARGS_HAVE);
220220
}
221221
my $int := intify($next);
222222
my $pad := padding_char($/);
@@ -401,7 +401,7 @@ my module sprintf {
401401
method directive:sym<e>($/) {
402402
my $next := next_argument($/);
403403
CATCH {
404-
bad-type-for-directive($next, 'e');
404+
bad-type-for-directive($next, 'e', @*ARGS_HAVE);
405405
}
406406
my $float := floatify($next);
407407
my $precision := $<precision> ?? $<precision>.made !! 6;
@@ -412,7 +412,7 @@ my module sprintf {
412412
method directive:sym<f>($/) {
413413
my $next := next_argument($/);
414414
CATCH {
415-
bad-type-for-directive($next, 'f');
415+
bad-type-for-directive($next, 'f', @*ARGS_HAVE);
416416
}
417417
my $int := floatify($next);
418418
my $precision := $<precision> ?? $<precision>.made !! 6;
@@ -423,7 +423,7 @@ my module sprintf {
423423
method directive:sym<g>($/) {
424424
my $next := next_argument($/);
425425
CATCH {
426-
bad-type-for-directive($next, 'g');
426+
bad-type-for-directive($next, 'g', @*ARGS_HAVE);
427427
}
428428
my $float := floatify($next);
429429
my $precision := $<precision> ?? $<precision>.made !! 6;
@@ -434,7 +434,7 @@ my module sprintf {
434434
method directive:sym<o>($/) {
435435
my $next := next_argument($/);
436436
CATCH {
437-
bad-type-for-directive($next, 'o');
437+
bad-type-for-directive($next, 'o', @*ARGS_HAVE);
438438
}
439439
my $int := intify($next);
440440
$int := nqp::base_I($int, 8);
@@ -453,7 +453,7 @@ my module sprintf {
453453
method directive:sym<s>($/) {
454454
my $next := next_argument($/);
455455
CATCH {
456-
bad-type-for-directive($next, 's');
456+
bad-type-for-directive($next, 's', @*ARGS_HAVE);
457457
}
458458
my $string := $next;
459459
if nqp::chars($<precision>) && nqp::chars($string) > $<precision>.made {
@@ -466,7 +466,7 @@ my module sprintf {
466466
method directive:sym<u>($/) {
467467
my $next := next_argument($/);
468468
CATCH {
469-
bad-type-for-directive($next, 'u');
469+
bad-type-for-directive($next, 'u', @*ARGS_HAVE);
470470
}
471471
my $int := intify($next);
472472
if nqp::islt_I($int, $zero) {
@@ -480,7 +480,7 @@ my module sprintf {
480480
method directive:sym<x>($/) {
481481
my $next := next_argument($/);
482482
CATCH {
483-
bad-type-for-directive($next, 'x');
483+
bad-type-for-directive($next, 'x', @*ARGS_HAVE);
484484
}
485485
my $int := intify($next);
486486
$int := nqp::base_I($int, 16);

0 commit comments

Comments
 (0)