New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rakudo cannot take the minimum of undef #552
Comments
From @masakRakudo r34628: $ perl6 -e 'undef min 2' |
From @moritzCarl MXXsak (via RT) wrote:
Added tests to t/spec/S03-operators/misc.t (but I don't know what the Cheers, |
The RT System itself - Status changed from 'new' to 'open' |
From @bacekOn Mon Jan 05 11:53:29 2009, moritz wrote:
Part of this bug fixed in #61840. Attached patch adds VTABLE_cmp for Undef in Parrot. Other approach is to -- |
From @bacekundef.patchcommit 948c9412c390b86cf68eaf5cc76525e050a1e100
Author: Vasily Chekalkin <bacek@bacek.com>
Date: Sat Feb 14 18:24:13 2009 +1100
Implement Undef.cmp
diff --git a/src/pmc/undef.pmc b/src/pmc/undef.pmc
index ed949a0..0bde497 100644
--- a/src/pmc/undef.pmc
+++ b/src/pmc/undef.pmc
@@ -245,6 +245,25 @@ Returns 1 if the C<*value> is an Undef PMC, 0 otherwise.
MULTI INTVAL is_equal(DEFAULT value) {
return 0;
}
+
+/*
+
+=item C<INTVAL cmp(PMC *value)>
+
+Returns 1 if the C<*value> is an Undef PMC, otherwise delegate comparition to value.
+
+=cut
+
+*/
+
+ MULTI INTVAL cmp(Undef value) {
+ return 1;
+ }
+
+ MULTI INTVAL cmp(DEFAULT value) {
+ return VTABLE_cmp(INTERP, value, SELF);
+ }
+
}
/*
|
From @ronaldxsAs demonstrated by the test script and output below, run with the Test script: ******************* say 'next step is undef min 2'; Test script output: ******************* Ron |
From @ronaldxsundef_almost_fix.patchIndex: src/pmc/undef.pmc
===================================================================
--- src/pmc/undef.pmc (revision 36800)
+++ src/pmc/undef.pmc (working copy)
@@ -245,6 +245,28 @@
MULTI INTVAL is_equal(DEFAULT value) {
return 0;
}
+
+
+/*
+
+=item C<INTVAL cmp(PMC *value)>
+
+Returns 1 if the C<*value> is an Undef PMC, otherwise delegate comparition to value.
+
+=cut
+
+*/
+
+
+ MULTI INTVAL cmp(Undef value) {
+ return 0;
+ }
+
+ MULTI INTVAL cmp(DEFAULT value) {
+ return -1 * VTABLE_cmp(INTERP, value, SELF);
+ }
+
+
}
/*
|
From @ronaldxsfailure_misc.patchdiff --git a/src/classes/List.pir b/src/classes/List.pir
index 4375e6f..6c3ba7d 100644
--- a/src/classes/List.pir
+++ b/src/classes/List.pir
@@ -571,8 +571,8 @@ have_args:
# Find minimum.
.local pmc cur_min, it
- cur_min = args[0]
it = iter args
+ cur_min = shift it
find_min_loop:
unless it goto find_min_loop_end
$P0 = shift it
Index: t/spec/S03-operators/misc.t
===================================================================
--- t/spec/S03-operators/misc.t (revision 25359)
+++ t/spec/S03-operators/misc.t (working copy)
@@ -124,8 +124,8 @@
# L<S03/Tight or precedence/"any value of any type may be compared with +Inf
# or -Inf values">
-#?rakudo todo 'RT #61836'
{
- lives_ok { (2 min undef) }, 'can do (2 min undef)';
- lives_ok { (undef min 2) }, 'can do (undef min 2)';
+ # from 'RT #61836'
+ ok ( not defined (2 min undef), 'can do (2 min undef)');
+ ok ( not defined (undef min 2), 'can do (undef min 2)');
}
|
From @ronaldxsFailure.patchdiff --git a/src/classes/Failure.pir b/src/classes/Failure.pir
index 7a78d5a..7b4a8e7 100644
--- a/src/classes/Failure.pir
+++ b/src/classes/Failure.pir
@@ -124,6 +124,42 @@
.return (self)
.end
+=comment
+
+The cmp and cmp_num vtable methods below fix problems that really
+should be fixed in the parrot undef.pmc file when parrot trac #285
+is fixed because C<'abc' cmp undef> works through the parrot pmc
+level now. These methods enable/fix C<undef cmp 'abc'>,
+C<undef E<lt>=E<gt> 2>, etc. more or less correctly for the time being.
+
+=cut
+
+.sub 'cmp' :vtable :method
+ .param pmc value
+ $I0 = isa value, 'Failure'
+ if $I0 goto ret_zero
+ $I0 = cmp value, self
+ $I0 = - $I0
+ .return ($I0)
+ret_zero:
+ $S0 = self # exception (string here might change but OK for now)
+ $S0 = value # exception (string here might change but OK for now)
+ .return (0)
+.end
+
+.sub 'cmp_num' :vtable :method
+ .param pmc value
+ $I0 = isa value, 'Failure'
+ if $I0 goto ret_zero
+ $I0 = cmp_num value, self
+ $I0 = - $I0
+ .return ($I0)
+ret_zero:
+ $I0 = self # exception
+ $I0 = value # exception
+ .return (0)
+.end
+
# Local Variables:
# mode: pir
|
From @masak<masak> rakudo: undef min 100 Expected result: undef, I think. Unless the 'min' numifies the result |
From @ronaldxsOn Thu Feb 19 05:27:45 2009, masak wrote:
With my proposed patches applied on my system: $ ./perl6 -e 'my $x = undef min 100; say $x.perl' |
From @moritz$ ./perl6 -e 'say Any min 2' you will be pleased... |
@moritz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#61836 (status was 'resolved')
Searchable as RT61836$
The text was updated successfully, but these errors were encountered: