You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Doing some tests with Kavorka features show me an issue when the last parameter has a default value.
Here are some tests to add to t/80returntype.t:
diff --git a/t/80returntype.t b/t/80returntype.t
index dbb4a14..fa2d185 100644
--- a/t/80returntype.t+++ b/t/80returntype.t@@ -67,4 +67,23 @@ is_deeply( [add3(4,5)], [4,5] );
like(exception { my @r = add3(4.1,4.9) }, qr{did not pass type constraint "ArrayRef.Int." at \S+ line 67});
like(exception { my @r = add3(4.1,5) }, qr{did not pass type constraint "ArrayRef.Int." at \S+ line 68});
+fun add4($a, $b? → Int){+ if ($b) {+ return $a + $b;+ }+ else {+ return $a+1;+ }+}++is( add4(1,2), 3, 'return type constraint works with optional parameter set');+is( add4(1), 2, 'return type constraint works with optional parameter unset');++fun add5($a, $b = 1 → Int) {+ return $a + $b;+}++is( add4(1,2), 3, 'return type constraint works with default parameter set');+is( add4(1), 2, 'return type constraint works with default parameter unset');+
done_testing;
The test does not compile at all:
prove -rlv t/80returntype.t
t/80returntype.t .. Unrecognized character \x{2192}; marked by <-- HERE after a, $b = 1 <-- HERE near column 21 at t/80returntype.t line 82.
Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run
Test Summary Report
-------------------
t/80returntype.t (Wstat: 65280 Tests: 0 Failed: 0)
Non-zero exit status: 255
Parse errors: No plan found in TAP output
Files=1, Tests=0, 1 wallclock secs ( 0.02 usr 0.00 sys + 0.28 cusr 0.01 csys = 0.31 CPU)
Result: FAIL
I tracked the problem up to Kavorka::Parameter::parse
perl -I lib/ -d t/80returntype.t
Loading DB routines from perl5db.pl version 1.49_05
Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
Kavorka::Parameter::parse(lib/Kavorka/Parameter.pm:275):
275: $default_when = $1;
DB<1> n
Kavorka::Parameter::parse(lib/Kavorka/Parameter.pm:276):
276: lex_read(length($1));
DB<1>
Kavorka::Parameter::parse(lib/Kavorka/Parameter.pm:277):
277: lex_read_space;
278: $default = lex_peek(5) =~ m{ \A (?: when\b | [,)] ) }x
DB<1>
Kavorka::Parameter::parse(lib/Kavorka/Parameter.pm:280):
280: : parse_arithexpr;
DB<1>
Unrecognized character \x{2192}; marked by <-- HERE after a, $b = 1 <-- HERE near column 21 at t/80returntype.t line 82.
at lib/Kavorka/Signature.pm line 73.
Kavorka::Signature::parse("Kavorka::Signature", "package", "main", "_is_dummy", 0) called at lib/Kavorka/Sub.pm line 221
Kavorka::Sub::parse_signature(Kavorka::Sub::Fun=HASH(0x561606be0968)) called at lib/Kavorka/Sub.pm line 123
Kavorka::Sub::parse("Kavorka::Sub::Fun", "keyword", "fun") called at lib/Kavorka.pm line 187
Kavorka::parse_fun("fun") called at t/80returntype.t line 82
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
Regards.
The text was updated successfully, but these errors were encountered:
Hello,
Doing some tests with Kavorka features show me an issue when the last parameter has a default value.
Here are some tests to add to t/80returntype.t:
The test does not compile at all:
I tracked the problem up to
Kavorka::Parameter::parse
Set a debug point:
Which results in the following trace:
Regards.
The text was updated successfully, but these errors were encountered: