[perl #127980] Smartmatching $item ~~ list does not DWIM (4 ~~ (4,5,6,7))

2016-04-24 Thread via RT
# New Ticket Created by  Alex Jakimenko 
# Please include the string:  [perl #127980]
# in the subject line of all future correspondence about this issue. 
# https://rt.perl.org/Ticket/Display.html?id=127980 >


Code:
say 4 ~~ (4,5,6,7)

Result:
False

Most people expect that it will check if the list on the RHS contains 4, but 
that's not what it does. The right way to do it is to use any(4,5,6,7).

Another thing that it could possibly do is to count the number of elements in 
the list, as in 4 == +(4,5,6,7), but again that's not what it does.

Example above clearly shows that both of these assumptions are wrong.

So what does it do?

The relevant piece of code is here: 
https://github.com/rakudo/rakudo/blob/nom/src/core/List.pm#L426 . In other 
words, it always returns False, but it also returns empty list if RHS list is 
empty or a RHS list itself if the first element of it is a Match object.

Does it make any sense? Not at all, at least to a typical user.


The proposal is to make it DWIM. That is, make 4 ~~ (4,5,6,7) work like 4 
(elem) (4,5,6,7).

See also IRC log: http://irclog.perlgeek.de/perl6/2016-04-24#i_12386065


Re: [perl #127977] AutoReply: [BUG] Constraint on a slurpy MAIN parameter leaks out internal exceptions

2016-04-24 Thread Tadeusz Sośnierz

https://github.com/rakudo/rakudo/tree/rt-127977 contains a fix for that

On 24/04/16 12:28, perl6 via RT wrote:

Greetings,

This message has been automatically generated in response to the
creation of a trouble ticket regarding:
"[BUG] Constraint on a slurpy MAIN parameter leaks out internal 
exceptions",
a summary of which appears below.

There is no need to reply to this message right now.  Your ticket has been
assigned an ID of [perl #127977].

Please include the string:

  [perl #127977]

in the subject line of all future correspondence about this issue. To do so,
you may reply to this message.

 Thank you,
 perl6-bugs-follo...@perl.org

-
$ cat test.pl
sub MAIN(@args where sub { False }) {
  say ":)"
}

$ perl6 test.pl
Usage:
test.pl 



$ cat test.pl # note the slurpy
sub MAIN(*@args where sub { False }) {
  say ":)"
}

$ perl6 test.pl
Constraint type check failed for parameter '@args'
in sub MAIN at test.pl line 1
in block  at test.pl line 1

--

I expect USAGE in both cases, since it's both exactly invalid use of MAIN.
Patch and spectest incoming.





[perl #126823] [MoarVM] Failing test in S32-array/adverbs.t and S32-hash/adverbs.t: Code does not die as expected with 'use '

2016-04-24 Thread Christian Bartolomaeus via RT
On Sun Apr 24 02:45:35 2016, barto...@gmx.de wrote:
> Alas, the tests in S32-hash/adverbs.t and S32-array/adverbs.t still do
> not pass. Will try to find a new/better golf.

Not as short as I hoped (it needs Test.pm6), but this is what currently fails 
in S32-hash/adverbs.t:

$ perl6-m -Ilib -e 'use Test; my %h; is %h:p(False), (B=>Any); throws-like 
q[%h:k:v], Exception, "test 2"; throws-like q[say %h:baxter], Exception, 
"test 3";'
Use of uninitialized value %h of type Any in string context
Any of .^name, .perl, .gist, or .say can stringify undefined things, if needed. 
 in block  at 
/usr/home/christian/perl6/perl6-roast-data/rakudo.moar/lib/Test.pm6 (Test) line 
136
Use of uninitialized value of type Any in string context
Any of .^name, .perl, .gist, or .say can stringify undefined things, if needed. 
 in block  at 
/usr/home/christian/perl6/perl6-roast-data/rakudo.moar/lib/Test.pm6 (Test) line 
136
ok 1 - 
1..2
ok 1 - '%h:k:v' died
ok 2 - right exception type (Exception)
ok 2 - test 2
1..2
(Any)
not ok 1 - 'say %h:baxter' died

# Failed test ''say %h:baxter' died'
# at -e line 1
ok 2 - \# SKIP Code did not die, can not check exception
# Looks like you failed 1 test of 2
not ok 3 - test 3

# Failed test 'test 3'
# at -e line 1

If one uses 'is-deeply' instead of 'is', the tests pass. Also with 
MVM_SPESH_DISABLE=1 the tests pass:

$ MVM_SPESH_DISABLE=1 perl6-m -Ilib -e 'use Test; my %h; is %h:p(False), 
(B=>Any); throws-like q[%h:k:v], Exception, "test 2"; throws-like q[say 
%h:baxter], Exception, "test 3";'
Use of uninitialized value %h of type Any in string context
Any of .^name, .perl, .gist, or .say can stringify undefined things, if needed. 
 in block  at 
/usr/home/christian/perl6/perl6-roast-data/rakudo.moar/lib/Test.pm6 (Test) line 
136
Use of uninitialized value of type Any in string context
Any of .^name, .perl, .gist, or .say can stringify undefined things, if needed. 
 in block  at 
/usr/home/christian/perl6/perl6-roast-data/rakudo.moar/lib/Test.pm6 (Test) line 
136
ok 1 - 
1..2
ok 1 - '%h:k:v' died
ok 2 - right exception type (Exception)
ok 2 - test 2
1..2
ok 1 - 'say %h:baxter' died
ok 2 - right exception type (Exception)
ok 3 - test 3



[perl #127916] [BUG] Inaccurate assignment to $!shortname in cases where a mixin happens during BUILD time.

2016-04-24 Thread Pepe Schwarz via RT
On Wed Apr 20 02:54:29 2016, jn...@jnthn.net wrote:
> On Sun Apr 17 16:34:02 2016, pesc...@gmail.com wrote:
> > Consider the following snippet:
> >
> > 23:28 < psch> m: role Bar::Foo { }; class A { submethod BUILD { self
> > does Bar::Foo } }; A.new.WHAT.say
> > 23:28 <+camelia> rakudo-moar 617bb4: OUTPUT«(Foo})␤»
> >
> > Clearly, A is not of type 'Foo}'. As far as I can tell
> > Perl6::Metamodel::Naming is involved, although I'm not sure why this
> > only happens with mixins during BUILD. I'd expect .WHAT to report
> > 'A+{Bar::Foo}' instead.
> 
> Nothing to do build BUILD. It golfs to:
> 
> role Foo::Bar { }; say (42 but Foo::Bar).^shortname
> 
> And it'll be because of this overly-naive code:
> 
> https://github.com/rakudo/rakudo/blob/nom/src/Perl6/Metamodel/Naming.nqp#L6
> 
> Maybe set_name should take an optional second parameter for the short
> name, and the mixin code can set it explicitly.
> 
> /jnthn

Fixed in Rakudo commit 60550d15, test added in roast commit 95a5c18.


[perl #127977] [BUG] Constraint on a slurpy MAIN parameter leaks out internal exceptions

2016-04-24 Thread via RT
# New Ticket Created by  Tadeusz Sośnierz 
# Please include the string:  [perl #127977]
# in the subject line of all future correspondence about this issue. 
# https://rt.perl.org/Ticket/Display.html?id=127977 >


$ cat test.pl
sub MAIN(@args where sub { False }) {
 say ":)"
}

$ perl6 test.pl
Usage:
   test.pl 



$ cat test.pl # note the slurpy
sub MAIN(*@args where sub { False }) {
 say ":)"
}

$ perl6 test.pl
Constraint type check failed for parameter '@args'
   in sub MAIN at test.pl line 1
   in block  at test.pl line 1

--

I expect USAGE in both cases, since it's both exactly invalid use of MAIN.
Patch and spectest incoming.


[perl #126823] [MoarVM] Failing test in S32-array/adverbs.t and S32-hash/adverbs.t: Code does not die as expected with 'use '

2016-04-24 Thread Christian Bartolomaeus via RT
My golfed test cases do no longer fail.

$ for run in {1..10}; do (echo '#' > Bar.pm6; ./perl6-m -I. -e 'use Bar; my %h 
= b => 2; say %h:zorp' 2>&1; ./perl6-m -I. -e 'use Bar; my %h = b => 2; say 
%h:zorp' 2>&1) | grep -c 'Unexpected named parameter'; done
2
2
2
2
2
2
2
2
2
2

Alas, the tests in S32-hash/adverbs.t and S32-array/adverbs.t still do not 
pass. Will try to find a new/better golf.