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

Int.Capture is empty #5357

Closed
p6rt opened this issue Jun 5, 2016 · 7 comments
Closed

Int.Capture is empty #5357

p6rt opened this issue Jun 5, 2016 · 7 comments
Labels
RFC Request For Comments

Comments

@p6rt
Copy link

p6rt commented Jun 5, 2016

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

Searchable as RT128321$

@p6rt
Copy link
Author

p6rt commented Jun 5, 2016

From @gfldex

dd 10.Capture, 0.5.Capture;
# OUTPUT«\()␤\(​:denominator(2), :numerator(1))␤»
# expected OUTPUT«\(10)␤\(​:denominator(2), :numerator(1))␤»

# this leads to odd behaviour for

sub returns-different-things () { ((10,"ten"), 10).pick };
given returns-different-things() {
  when :(Int, Str) { say 'It returned a list.' };
  when :(Int) { say 'returned a single Int' };
  default { say 'This should never happen' }
}

# OUTPUT«This should never happen␤»

@p6rt
Copy link
Author

p6rt commented Jun 5, 2016

From @lizmat

On 05 Jun 2016, at 09​:52, Wenzel Peppmeyer (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Wenzel Peppmeyer
# Please include the string​: [perl #​128321]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=128321 >

dd 10.Capture, 0.5.Capture;
# OUTPUT«\()␤\(​:denominator(2), :numerator(1))␤»
# expected OUTPUT«\(10)␤\(​:denominator(2), :numerator(1))␤»

# this leads to odd behaviour for

sub returns-different-things () { ((10,"ten"), 10).pick };
given returns-different-things() {
when :(Int, Str) { say 'It returned a list.' };
when :(Int) { say 'returned a single Int' };
default { say 'This should never happen' }
}

# OUTPUT«This should never happen␤»

I tried making Mu.Capture take self as a positional, but that causes all sorts of spectest breakage. *AND* it didn’t make the example work.

I’m not sure what the best cause of action is.

Liz

@p6rt
Copy link
Author

p6rt commented Jun 5, 2016

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

@p6rt
Copy link
Author

p6rt commented Jun 5, 2016

From @lizmat

On 05 Jun 2016, at 09​:52, Wenzel Peppmeyer (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Wenzel Peppmeyer
# Please include the string​: [perl #​128321]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=128321 >

dd 10.Capture, 0.5.Capture;
# OUTPUT«\()␤\(​:denominator(2), :numerator(1))␤»
# expected OUTPUT«\(10)␤\(​:denominator(2), :numerator(1))␤»

# this leads to odd behaviour for

sub returns-different-things () { ((10,"ten"), 10).pick };
given returns-different-things() {
when :(Int, Str) { say 'It returned a list.' };
when :(Int) { say 'returned a single Int' };
default { say 'This should never happen' }
}

# OUTPUT«This should never happen␤»

Maybe it is ENOTABUG​:

sub returns-different-things () { ((10,"ten"), 10).pick };
given returns-different-things() {
  when :(Int, Str) { say 'It returned a list.' };
  when Int { say 'returned a single Int' }; # <— just Int will do for scalar values
  default { say 'This should never happen' }
}

gives the expected result.

Liz

@p6rt
Copy link
Author

p6rt commented Jun 6, 2016

From @gfldex

On Sun, 5 Jun 2016, Elizabeth Mattijsen via RT wrote​:

On 05 Jun 2016, at 09​:52, Wenzel Peppmeyer (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Wenzel Peppmeyer
# Please include the string​: [perl #​128321]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=128321 >

dd 10.Capture, 0.5.Capture;
# OUTPUT«\()␤\(​:denominator(2), :numerator(1))␤»
# expected OUTPUT«\(10)␤\(​:denominator(2), :numerator(1))␤»

# this leads to odd behaviour for

sub returns-different-things () { ((10,"ten"), 10).pick };
given returns-different-things() {
when :(Int, Str) { say 'It returned a list.' };
when :(Int) { say 'returned a single Int' };
default { say 'This should never happen' }
}

# OUTPUT«This should never happen␤»

Maybe it is ENOTABUG​:

sub returns-different-things () { ((10,"ten"), 10).pick };
given returns-different-things() {
when :(Int, Str) { say 'It returned a list.' };
when Int { say 'returned a single Int' }; # <— just Int will do for scalar values
default { say 'This should never happen' }
}

gives the expected result.

Indeed. However, I am surprised by the following.

dd 10 ~~ :(Int), (10,) ~~ :(Int)
# OUTPUT«Bool​::False␤Bool​::True␤»

I can doc that there is a special case for matching against signature
literals when single values are involved. I would prefere if Rakudo
would DWIM.

@p6rt
Copy link
Author

p6rt commented Oct 9, 2017

From @zoffixznet

On Sun, 05 Jun 2016 00​:52​:54 -0700, gfldex wrote​:

Thank you for the report. This ticket is now resolved.

Impl​: rakudo/rakudo@4ba12ff
  rakudo/rakudo@bad9fef
  rakudo/rakudo@cd5864c
  rakudo/rakudo@27131ed

Spec​: Raku/roast@ca27350
  Raku/roast@48d5d39

Docs​: Raku/doc@88ef45e
  Raku/doc@12ec0ca

@p6rt
Copy link
Author

p6rt commented Oct 9, 2017

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

@p6rt p6rt closed this as completed Oct 9, 2017
@p6rt p6rt added the RFC Request For Comments label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC Request For Comments
Projects
None yet
Development

No branches or pull requests

1 participant