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
Bare return; should return Nil. #306
Comments
From @masakThe `return` built-in doesn't take zero arguments, like it can in Perl $ cat return_undef.pl $ cat return.pl $ patch -p0 < zero-arg-return.patch ; make perl6 $ ./perl6 return.pl $ |
From @masakzero-arg-return.patchIndex: src/builtins/control.pir
===================================================================
--- src/builtins/control.pir (revision 29090)
+++ src/builtins/control.pir (working copy)
@@ -26,7 +26,13 @@
.include 'except_types.pasm'
.sub 'return'
- .param pmc value
+ .param pmc value :optional
+ .param int has_value :opt_flag
+
+ if has_value goto have_value
+ get_global $P1, "Failure"
+ value = $P1."new"()
+ have_value:
$P0 = new 'Exception'
$P0['_type'] = .CONTROL_RETURN
setattribute $P0, 'payload', value
|
@pmichaud - Status changed from 'new' to 'open' |
From @pmichaudApplied (with one minor change) in r29143, thanks! Note however that TimToady on #perl6 speculated [1] that an empty return Thanks! |
1 similar comment
From @pmichaudApplied (with one minor change) in r29143, thanks! Note however that TimToady on #perl6 speculated [1] that an empty return Thanks! |
From @TimToadyOn Mon, Jul 07, 2008 at 07:16:05PM -0700, Patrick R. Michaud via RT wrote: A C<return> just returns its argument list as a Capture, so it's Larry |
From @pmichaudOn Mon, Jul 07, 2008 at 08:18:36PM -0700, Larry Wall wrote:
By "(undef)" here did you mean simply that it's an undefined Thanks, Pm |
From @TimToadyOn Mon, Jul 07, 2008 at 11:43:56PM -0500, Patrick R. Michaud wrote: Hmm, well, on further reflections, it should in all likelihood be I can also argue that a null list in item context simply promotes to It does treat single-item lists as special, but note that .[0] is Which argues that bare return should be treated as returning a list So $x = nothing(); # = [] In other words, I think I'd like to not encourage people to use bare Larry |
From @TimToadyOn Mon, Jul 07, 2008 at 10:09:37PM -0700, Larry Wall wrote: But note that binding the returned capture also fails: $x := nothing(); just as calling foo() without args can't bind to a sig with required sub foo ($x) {...} Binding to $x is more like looking for .[0], in other words. Note however that when you call foo(nothing()) you're really passing a Capture with 1 positional element, which foo(threeitems()) would bind an array of 3 elements. Larry |
From @moritzA recent change in the test suite made three rakudo tests fail (although sub bar { return } (from t/spec/S04-statements/return.t) I TODO'ed them now (to make spectest_regression clean again), and opened Moritz -- |
From @moritzMerging into 58770, because the discussion here is relevant over there See also: |
From @pmichaudNow fixed in r33898, thanks! Pm |
@pmichaud - Status changed from 'new' to 'resolved' |
Migrated from rt.perl.org#58770 (status was 'resolved')
Searchable as RT58770$
The text was updated successfully, but these errors were encountered: