bin1RaOEEkumK.bin
Description:
Index: t/01-sanity/07-substr.t
===================================================================
--- t/01-sanity/07-substr.t (revision 24949)
+++ t/01-sanity/07-substr.t (working copy)
@@ -1,9 +1,13 @@
use v6-alpha;
-say "1..1";
+say "1..3";
my $string = "Pugs -- Perl6 User's Golfing System";
my $substr = substr $string, 8, 5;
if $substr eq "Perl6" { say "ok 1" } else { say "not ok 1" }
+
+my $str = 'not ok ';
+say substr( $str, 4 ) ~ "2";
+say substr( $str, 4 ), "3";
Index: src/builtins/string.pir
===================================================================
--- src/builtins/string.pir (revision 24949)
+++ src/builtins/string.pir (working copy)
@@ -186,7 +186,16 @@
.sub 'substr'
.param string x
.param int start
- .param int len
+ .param int len :optional
+ .param int has_len :opt_flag
+ .local pmc s
+
+ if has_len goto end
+ s = new 'Perl6Str'
+ s = x
+ len = s.'chars'()
+
+ end:
$S0 = substr x, start, len
.return ($S0)
.end
