Skip to content
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

convert 'new Failure' to '!FAIL' #301

Closed
p6rt opened this issue Sep 7, 2008 · 8 comments
Closed

convert 'new Failure' to '!FAIL' #301

p6rt opened this issue Sep 7, 2008 · 8 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 7, 2008

Migrated from rt.perl.org#58646 (status was 'resolved')

Searchable as RT58646$

@p6rt
Copy link
Author

p6rt commented Sep 7, 2008

From @pmichaud

For rakudo builtin functions that are written in PIR, use

  .return '!FAIL'('...message...')

instead of the old-style

  $P0 = new 'Failure'
  .return ($P0)

Functions that have return exception handlers in place
(i.e., those written in Perl 6) should simply call 'fail'
directly​:

  fail '...';

Pm

@p6rt
Copy link
Author

p6rt commented Sep 8, 2008

From @ronaldxs

On Sun Sep 07 10​:29​:52 2008, pmichaud wrote​:

For rakudo builtin functions that are written in PIR, use

\.return '\!FAIL'\('\.\.\.message\.\.\.'\)

instead of the old-style

$P0 = new 'Failure'
\.return \($P0\)

The attached patches address part of the stated problem. I will try to
document here some of the areas that will likely need to be handled
later.

In languages/perl6/src/classes/List.pir​:
both map and reduce attempt to return Failure for null iterator values
in some circumstances. I could not figure out how to reproduce those
conditions to patch those methods. I discussed a question regarding
the results of reduce with a null element in the input list with moritz
via irc#perl6 on 9/8/08.

In languages/perl6/src/classes/Object.pir​:
I managed to fix and test obj.?no_such_meth. I had no luck testing .+

In languages/perl6/src/classes/Code.pir​:
The signature method probably needs to be adjusted but had some
difficulty getting test results from it.

I may have missed a pir 'Failure' object creation or so somewhere but
this seems to be most of it.

@p6rt
Copy link
Author

p6rt commented Sep 8, 2008

From @ronaldxs

failure_mod.patch
Index: src/classes/Array.pir
===================================================================
--- src/classes/Array.pir	(revision 30888)
+++ src/classes/Array.pir	(working copy)
@@ -132,7 +132,7 @@
     x = pop self
     goto done
   empty:
-    x = new 'Failure'
+    x = '!FAIL'('Undefined value popped from empty array')
   done:
     .return (x)
 .end
@@ -165,7 +165,7 @@
     x = shift self
     goto done
   empty:
-    x = new 'Failure'
+    x = '!FAIL'('Undefined value shifted from empty array')
   done:
     .return (x)
 .end
Index: src/classes/List.pir
===================================================================
--- src/classes/List.pir	(revision 30888)
+++ src/classes/List.pir	(working copy)
@@ -256,8 +256,7 @@
     goto done
 
   nomatch:
-    retv = new 'Failure'
-    goto done
+    retv = '!FAIL'('Undefined value - first list match of no matches')
 
   done:
     .return(retv)
Index: src/classes/Object.pir
===================================================================
--- src/classes/Object.pir	(revision 30888)
+++ src/classes/Object.pir	(working copy)
@@ -428,8 +428,7 @@
     # For now we won't worry about signature, just if a method exists.
     $I0 = can self, method_name
     if $I0 goto invoke
-    $P0 = get_hll_global 'Failure'
-    .return ($P0)
+    .return '!FAIL'('Undefined value returned by invocation of undefined method')
 
     # If we do have a method, call it.
   invoke:

@p6rt
Copy link
Author

p6rt commented Sep 8, 2008

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 1, 2008

From @moritz

On Mon Sep 08 13​:49​:44 2008, ronaldxs wrote​:

On Sun Sep 07 10​:29​:52 2008, pmichaud wrote​:

For rakudo builtin functions that are written in PIR, use

\.return '\!FAIL'\('\.\.\.message\.\.\.'\)

instead of the old-style

$P0 = new 'Failure'
\.return \($P0\)

The attached patches address part of the stated problem.

Thanks, applied as r31544.

Moritz

@p6rt
Copy link
Author

p6rt commented May 1, 2009

From @ronaldxs

Using find/grep to find calls to "new 'Failure'" in the current (non-
generated) rakudo code base I came up with the short list below. They
all seem to represent legitimate cases of wanting to allocate a Failure
object to return an undef type value like an index search that fails to
find its search string.

Suggesting the possible closing of this ticket.

src/builtins/any-str.pir​:184​: $P0 = new 'Failure'
src/builtins/any-str.pir​:246​: $P0 = new 'Failure'
src/builtins/control.pir​:59​: $P1 = new 'Failure'
src/builtins/control.pir​:379​: exception = new 'Failure'
src/builtins/io.pir​:25​: $P0 = new 'Failure'
src/classes/Failure.pir​:59​: $P0 = new 'Failure'
src/classes/Nil.pir​:55​: $P0 = new 'Failure'

@p6rt
Copy link
Author

p6rt commented Aug 19, 2009

From @jnthn

On Sun Sep 07 10​:29​:52 2008, pmichaud wrote​:

For rakudo builtin functions that are written in PIR, use

\.return '\!FAIL'\('\.\.\.message\.\.\.'\)

instead of the old-style

$P0 = new 'Failure'
\.return \($P0\)

Thanks to those who contributed patches towards this effort. I've just
hunted down and converted the last remaining new, and new the only case
of a new ['Failure'] that I can find is in '!FAIL' itself. Committed the
last few as git 9729b05, resolving ticket.

Jonathan

@p6rt
Copy link
Author

p6rt commented Aug 19, 2009

@jnthn - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Aug 19, 2009
@p6rt p6rt added the Todo label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant