[perl #131395] [BUG] Cross meta operator on empty list complains "This type (Scalar) does not support elems"

2019-05-12 Thread Jan-Olof Hendig via RT
On Sat, 30 Sep 2017 12:40:59 -0700, sml...@gmail.com wrote:
> On Mon, 29 May 2017 11:36:49 -0700, c...@zoffix.com wrote:
> > On Mon, 29 May 2017 10:02:27 -0700, thunderg...@comcast.net wrote:
> > > Using a cross meta operator on an empty list complains "This type
> > > (Scalar) does not support elems".
> > >
> > > say (1,2).elems; say ().elems; say (1,2) X ();
> > >
> > > yields "2␤0␤This type (Scalar) does not support elems"
> > >
> > > Seems to work correctly with arrays instead of lists.
> > >
> > > say [1,2].elems; say [].elems; say [1,2] X [];
> > >
> > >
> > > Linux Mint 17.2
> > >
> > >  > perl6 -v
> > >  >  This is Rakudo version 2017.05 built on MoarVM version 2017.05
> > > implementing Perl 6.c.
> >
> >
> > Thank you for the report. lizmat++ fixed the issue.
> >
> > Fix: https://github.com/rakudo/rakudo/commit/9494cbd3b9
> > Test: https://github.com/perl6/roast/commit/0faf3c354f
> 
> Re-opening, because it hasn't been fixed for the Xop case yet:
> 
> ➜  say () X+ (1, 2);
> This type (Scalar) does not support elems
> 
> ➜  say (1,2) X~ ();
> This type (Scalar) does not support elems
> 
> ➜  say () X=> ();
> This type (Scalar) does not support elems
> 
> Bisectable¹ blames a commit² from January.
> 
> 
> ---
> [1]
> https://gist.github.com/Whateverable/f1b3066f1e2c45df7ab5e0aa7aeee3a7
> [2] https://github.com/rakudo/rakudo/commit/a26f51361
> 
> ---
> This is Rakudo version 2017.09-142-ga89add0bf built on MoarVM version
> 2017.09.1-49-gb3dd812a
> implementing Perl 6.c.

Fixed with commit 
https://github.com/rakudo/rakudo/commit/6c93fde85da027748bddd7cf75e295ed70ce3b05
Roast tests added with 
https://github.com/perl6/roast/commit/7d47580eb83fbf7c315e21411422fbc547f96399

Closing


[perl #130572] Parenthesized `for` loop is eager, even with `lazy` keyword

2019-05-12 Thread Jan-Olof Hendig via RT
On Sat, 26 Aug 2017 05:15:41 -0700, sml...@gmail.com wrote:
> This bug is still present in
> 
> Rakudo version 2017.08-8-g753c9a5ea built on MoarVM version 2017.08.1-
> 19-g151a2563
> implementing Perl 6.c

As per commit 
https://github.com/rakudo/rakudo/commit/cf1673d9c20e82aad6291a8aa123c46e177edf34
the second case now works as intended.


[perl #130572] Parenthesized `for` loop is eager, even with `lazy` keyword

2019-05-12 Thread Jan-Olof Hendig via RT
On Sun, 12 May 2019 07:36:16 -0700, jan-olof.hen...@bredband.net wrote:
> On Sat, 26 Aug 2017 05:15:41 -0700, sml...@gmail.com wrote:
> > This bug is still present in
> >
> > Rakudo version 2017.08-8-g753c9a5ea built on MoarVM version
> > 2017.08.1-
> > 19-g151a2563
> > implementing Perl 6.c
> 
> As per commit
> https://github.com/rakudo/rakudo/commit/cf1673d9c20e82aad6291a8aa123c46e177edf34
> the second case now works as intended.

As for the first case, see 
https://colabti.org/irclogger/irclogger_log/perl6-dev?date=2019-05-12#l48

should be set to testneeded


[perl #130069] [BUG] Unknown QAST error when creating List of Pairs

2019-05-12 Thread Jan-Olof Hendig via RT
On Thu, 04 May 2017 17:36:32 -0700, c...@zoffix.com wrote:
> On Thu, 10 Nov 2016 21:03:43 -0800, joshu...@gmail.com wrote:
> > Normally Rakudo is happy for you to omit comma when declaring pairs
> > with
> > the `:key(value)` syntax, however I found that it does not like this
> > syntax
> > is Rat's are used as the value, like this:
> >
> > > (:this(3.5) :that(5.3))
> > Unknown QAST node type NQPMu
> >
> 
> I took a stab at this one, but giving up for now.
> 
> Things discovered:
> - It's the second `:that(5.3)` that is the thing causing the issue
> - To repro the issue, instead of a Rat you can use a constant, e.g.
> `:that(pi)`
> - ASTs:
> - Working version has: QAST::WVal(Rat)  :statement_id
> 5.3
> - Broken version has: QAST::Want  (looks like it's missing
> stuff inside of it, which is what gives the error)
> - --target=parse:
> - Working version has EXPR => - 0: colonpair: (first)  - 1:
> colonpair: (second)
> - Broken version has EXPR => - 0: colonpair: (first)  -
> fake_infix:   - OPER:   - colonpair: (second)
> 
> So looks like the Actions for `statement` token needs to rake through
> `fake_infix` capture and generate proper colonpair instead of empty
> QAST::Want.
> 
> I gave up at that point, but hopefully my digging will be helpful to
> someone :)

Fixed with commit 
https://github.com/rakudo/rakudo/commit/91359141fb7501636b073ccaf6fb6598dc273bec

testneeded


[perl #131089] Different parsing of combined colonpairs

2019-05-12 Thread Jan-Olof Hendig via RT
On Sun, 02 Apr 2017 07:48:11 -0700, alex.jakime...@gmail.com wrote:
> I wonder, is it a dup of RT #124553 and RT #125353 ?
> 
> On 2017-04-02 04:50:15, c...@zoffix.com wrote:
> > If joined colonpairs are after a position arg, only the first
> > colonpair gets registered:
> >
> >  m: -> *@_, *%_ { dd [@_, %_] }("/", :r:w:d:x)
> >  rakudo-moar 1b9d53: OUTPUT: «[["/"], {:r}]␤»
> >
> > But if they're first in line, then all do:
> >
> >  m: -> *@_, *%_ { dd [@_, %_] }(:r:w:d:x, "/")
> >  rakudo-moar 1b9d53: OUTPUT: «[["/"], {:d, :r, :w, :x}]␤»
> >
> > When in a [], only first one is obtained as well:
> >  m: dd [:r:w:d:x]
> >  rakudo-moar 1b9d53: OUTPUT: «[:r]␤»
> >
> > And when in a {}, all are obtained, but only the first one gets value
> > True (related?)
> >  m: dd {:r:w:d:x}
> >  rakudo-moar 1b9d53: OUTPUT: «Hash % = {:d(1), :r, :w(1),
> > :x(1)}␤»

The examples given by Zoffix above seems to have been fixed by 
https://github.com/rakudo/rakudo/commit/91359141fb7501636b073ccaf6fb6598dc273bec


Which TELNET options need to be supported in Net::Telnet?

2019-05-12 Thread Ben Davies
Net::Telnet is just about ready for release v0.0.1 now. Since it's on 
the most wanted modules list, I figured someone out there needs it and 
knows how the protocol works.

Currently, the library supports the TRANSMIT_BINARY, SGA, ECHO, and NAWS 
options. I'm planning on gradually adding support for more options over 
time, but I don't know which options people commonly use. Does anyone 
have any options they need support for that I can add in v0.0.2?



Re: valid values?

2019-05-12 Thread yary
Side note, using the angle brackets creates IntStr objects, which in some
cases is harmless, sometimes necessary.

> say <1 2 4 8 16 >.perl

(IntStr.new(1, "1"), IntStr.new(2, "2"), IntStr.new(4, "4"), IntStr.new(8,
"8"), IntStr.new(16, "16"))

> say (1,2,4,8,16).perl

(1, 2, 4, 8, 16)

That's thanks to allomorphs from quote-word -
https://docs.perl6.org/language/glossary#index-entry-Allomorph* "**Keep in
mind that certain constructs, such as sets, bags, and mixes care about
object identity, and so will not accept an allomorph as equivalent of its
components alone."*

I usually save angle brackets for strings but in this case, MAIN is getting
IntStr, so we have to also have IntStr for the Set operator element-of:

sub MAIN(Int $value where $value ∈ <1 2 4 8 16>) { say "\$value.perl =
",$value.perl }
perl6 main.p6 4
*says $value.perl = IntStr.new(4, "4")*

sub MAIN(Int $value where $value ∈ (1,2,4,8,16)) {say "\$value.perl =
",$value.perl }
perl6 main.p6 4
*says Type check failed in binding to parameter ''; expected Any but
got Mu (Mu)*
*  in block  at main.p6 line 1*

Which brings up another question- how to coerce $value to Int? These don't
work, even though IntStr has an Int() method.

sub MAIN(Int(IntStr) $value where $value ∈ (1,2,4,8,16)) {say "\$value.perl
= ",$value.perl }
sub MAIN(Int() $value where $value ∈ (1,2,4,8,16)) {say "\$value.perl =
",$value.perl }


-y


On Thu, Apr 18, 2019 at 5:31 PM mimosinnet  wrote:

> El Sunday, 03 de March del 2019 a les 02:09, ToddAndMargo via perl6-users
> va escriure:
>
> >I want to pass an integer to a sub.  The only
> >valid values of the integer are 1, 2, 4, 8, and 16.
> >
> >Other than using "if" to test their values, is
> >there a way to state that an integer can only
> >have certain predefined values?
>
> I like this syntax:
>
> sub MAIN(Int $value where $value ∈ <1 2 4 8 16 >) {
> 
> }
>
> It is readable and I really like to use the '∈' symbol :D.
>
> Cheers!
>
> --
> (≧∇≦) Mimosinnet (Linux User: #463211)
>


Re: Which TELNET options need to be supported in Net::Telnet?

2019-05-12 Thread yary
Whichever one lets env variables get passed- need to set TERM in particular.

-y


On Sun, May 12, 2019 at 3:28 PM Ben Davies  wrote:

> Net::Telnet is just about ready for release v0.0.1 now. Since it's on
> the most wanted modules list, I figured someone out there needs it and
> knows how the protocol works.
>
> Currently, the library supports the TRANSMIT_BINARY, SGA, ECHO, and NAWS
> options. I'm planning on gradually adding support for more options over
> time, but I don't know which options people commonly use. Does anyone
> have any options they need support for that I can add in v0.0.2?
>
>


Re: valid values?

2019-05-12 Thread yary
On #perl6  Int(IntStr) will not coerce because IntStr is already
an Int; coercions will only fire if the type doesn't match, like with Array
and Hash for example

IntStr is a subclass of Int thus no coercion needed to set $value. A
catch-22 if each right side element is Int as opposed to IntStr, because
Main gets an IntStr $value and the set-matching operation ∈ needs an exact
class match. There is a work-around:

# Be sure we are comparing with Int
sub MAIN(Int $value where Int($value) ∈ (1,2,4,8,16)) {say "\$value.perl =
",$value.perl }
# says *$value.perl = IntStr.new(4, "4")*

As an alternate workaround, I tried converting $value to Int while
comparing. That means $value needs to be writable, but the above plus
"$value is rw", fails:

sub MAIN(Int $value is rw where Int($value) ∈ (1,2,4,8,16)) {say
"\$value.perl = ",$value.perl }
# 6.c says *Cannot find method 'Int' on object of type NQPMu*
*# *6.d says Usage:␤   ␤

Without "$value is rw" working, the following also break.

sub MAIN(Int $value is rw where ($value += 0) ∈ (1,2,4,8,16)) {say
"\$value.perl = ",$value.perl }
sub MAIN(Int $value is rw where ($value = Int($value)) ∈ (1,2,4,8,16)) {say
"\$value.perl = ",$value.perl }

-y


On Sun, May 12, 2019 at 3:55 PM yary  wrote:

> Side note, using the angle brackets creates IntStr objects, which in some
> cases is harmless, sometimes necessary.
>
> > say <1 2 4 8 16 >.perl
>
> (IntStr.new(1, "1"), IntStr.new(2, "2"), IntStr.new(4, "4"), IntStr.new(8,
> "8"), IntStr.new(16, "16"))
>
> > say (1,2,4,8,16).perl
>
> (1, 2, 4, 8, 16)
>
> That's thanks to allomorphs from quote-word -
> https://docs.perl6.org/language/glossary#index-entry-Allomorph* "**Keep
> in mind that certain constructs, such as sets, bags, and mixes care about
> object identity, and so will not accept an allomorph as equivalent of its
> components alone."*
>
> I usually save angle brackets for strings but in this case, MAIN is
> getting IntStr, so we have to also have IntStr for the Set operator
> element-of:
>
> sub MAIN(Int $value where $value ∈ <1 2 4 8 16>) { say "\$value.perl =
> ",$value.perl }
> perl6 main.p6 4
> *says $value.perl = IntStr.new(4, "4")*
>
> sub MAIN(Int $value where $value ∈ (1,2,4,8,16)) {say "\$value.perl =
> ",$value.perl }
> perl6 main.p6 4
> *says Type check failed in binding to parameter ''; expected Any but
> got Mu (Mu)*
> *  in block  at main.p6 line 1*
>
> Which brings up another question- how to coerce $value to Int? These don't
> work, even though IntStr has an Int() method.
>
> sub MAIN(Int(IntStr) $value where $value ∈ (1,2,4,8,16)) {say
> "\$value.perl = ",$value.perl }
> sub MAIN(Int() $value where $value ∈ (1,2,4,8,16)) {say "\$value.perl =
> ",$value.perl }
>
>
> -y
>
>
> On Thu, Apr 18, 2019 at 5:31 PM mimosinnet  wrote:
>
>> El Sunday, 03 de March del 2019 a les 02:09, ToddAndMargo via perl6-users
>> va escriure:
>>
>> >I want to pass an integer to a sub.  The only
>> >valid values of the integer are 1, 2, 4, 8, and 16.
>> >
>> >Other than using "if" to test their values, is
>> >there a way to state that an integer can only
>> >have certain predefined values?
>>
>> I like this syntax:
>>
>> sub MAIN(Int $value where $value ∈ <1 2 4 8 16 >) {
>> 
>> }
>>
>> It is readable and I really like to use the '∈' symbol :D.
>>
>> Cheers!
>>
>> --
>> (≧∇≦) Mimosinnet (Linux User: #463211)
>>
>


Re: valid values?

2019-05-12 Thread yary
"is copy" is what I wanted to allow modifying MAIN's passed-in values. "is
rw" correctly rejects constants.

sub MAIN(Int $value is copy where ($value .= Int) ∈ (1,2,4,8,16)) {say
"\$value.perl = ",$value.perl }
# says $value.perl = 4

-y


On Sun, May 12, 2019 at 5:02 PM yary  wrote:

> On #perl6  Int(IntStr) will not coerce because IntStr is
> already an Int; coercions will only fire if the type doesn't match, like
> with Array and Hash for example
>
> IntStr is a subclass of Int thus no coercion needed to set $value. A
> catch-22 if each right side element is Int as opposed to IntStr, because
> Main gets an IntStr $value and the set-matching operation ∈ needs an exact
> class match. There is a work-around:
>
> # Be sure we are comparing with Int
> sub MAIN(Int $value where Int($value) ∈ (1,2,4,8,16)) {say "\$value.perl =
> ",$value.perl }
> # says *$value.perl = IntStr.new(4, "4")*
>
> As an alternate workaround, I tried converting $value to Int while
> comparing. That means $value needs to be writable, but the above plus
> "$value is rw", fails:
>
> sub MAIN(Int $value is rw where Int($value) ∈ (1,2,4,8,16)) {say
> "\$value.perl = ",$value.perl }
> # 6.c says *Cannot find method 'Int' on object of type NQPMu*
> *# *6.d says Usage:␤   ␤
>
> Without "$value is rw" working, the following also break.
>
> sub MAIN(Int $value is rw where ($value += 0) ∈ (1,2,4,8,16)) {say
> "\$value.perl = ",$value.perl }
> sub MAIN(Int $value is rw where ($value = Int($value)) ∈ (1,2,4,8,16))
> {say "\$value.perl = ",$value.perl }
>
> -y
>
>
> On Sun, May 12, 2019 at 3:55 PM yary  wrote:
>
>> Side note, using the angle brackets creates IntStr objects, which in some
>> cases is harmless, sometimes necessary.
>>
>> > say <1 2 4 8 16 >.perl
>>
>> (IntStr.new(1, "1"), IntStr.new(2, "2"), IntStr.new(4, "4"),
>> IntStr.new(8, "8"), IntStr.new(16, "16"))
>>
>> > say (1,2,4,8,16).perl
>>
>> (1, 2, 4, 8, 16)
>>
>> That's thanks to allomorphs from quote-word -
>> https://docs.perl6.org/language/glossary#index-entry-Allomorph* "**Keep
>> in mind that certain constructs, such as sets, bags, and mixes care about
>> object identity, and so will not accept an allomorph as equivalent of its
>> components alone."*
>>
>> I usually save angle brackets for strings but in this case, MAIN is
>> getting IntStr, so we have to also have IntStr for the Set operator
>> element-of:
>>
>> sub MAIN(Int $value where $value ∈ <1 2 4 8 16>) { say "\$value.perl =
>> ",$value.perl }
>> perl6 main.p6 4
>> *says $value.perl = IntStr.new(4, "4")*
>>
>> sub MAIN(Int $value where $value ∈ (1,2,4,8,16)) {say "\$value.perl =
>> ",$value.perl }
>> perl6 main.p6 4
>> *says Type check failed in binding to parameter ''; expected Any
>> but got Mu (Mu)*
>> *  in block  at main.p6 line 1*
>>
>> Which brings up another question- how to coerce $value to Int? These
>> don't work, even though IntStr has an Int() method.
>>
>> sub MAIN(Int(IntStr) $value where $value ∈ (1,2,4,8,16)) {say
>> "\$value.perl = ",$value.perl }
>> sub MAIN(Int() $value where $value ∈ (1,2,4,8,16)) {say "\$value.perl =
>> ",$value.perl }
>>
>>
>> -y
>>
>>
>> On Thu, Apr 18, 2019 at 5:31 PM mimosinnet  wrote:
>>
>>> El Sunday, 03 de March del 2019 a les 02:09, ToddAndMargo via
>>> perl6-users va escriure:
>>>
>>> >I want to pass an integer to a sub.  The only
>>> >valid values of the integer are 1, 2, 4, 8, and 16.
>>> >
>>> >Other than using "if" to test their values, is
>>> >there a way to state that an integer can only
>>> >have certain predefined values?
>>>
>>> I like this syntax:
>>>
>>> sub MAIN(Int $value where $value ∈ <1 2 4 8 16 >) {
>>> 
>>> }
>>>
>>> It is readable and I really like to use the '∈' symbol :D.
>>>
>>> Cheers!
>>>
>>> --
>>> (≧∇≦) Mimosinnet (Linux User: #463211)
>>>
>>