-
Notifications
You must be signed in to change notification settings - Fork 1
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
Junctions cause crash / infinite loop in &put and related routines and methods #6647
Comments
From @briandfoyThis comes from an answer to a Perl 6 question on Stackoverflow that https://stackoverflow.com/q/45527881/2766176 With put() it does not and gives a strange error: $ perl6 -e 'put any( 1, 3, 7 ) ' $ perl6 -e 'put( any( 1, 3, 7 ) )' With say it has no problem: $ perl6 -e 'say any( 1, 3, 7 )' I'd expect anything that can .gist would be able to .Str. This is Rakudo 2017.10 on macOS 10.13. |
From @zoffixznetOn Fri, 08 Dec 2017 08:28:32 -0800, comdog wrote:
I guess jnthn++ gets a score point for predicting[^1] this would happen: <jnthn> Hmmm...not too keen on the Junction.Str patch If put() were made to work here, I'd expect it to junct and be equivalent to `put 1`, `put 3`, `put 7` executed in random order, but the OP in that SO has an entirely different expectation.
Side note on that: only the opposite is true. A basic class would .gist to its name, while its .Str would be an empty string accompanied by a warning. Also, some things, like self-referential structures or non-lazy infinite iterables, would take an infinite time to .Str, while getting .gisted is no trouble. [1] https://irclog.perlgeek.de/perl6-dev/2017-08-09#i_14992203 |
The RT System itself - Status changed from 'new' to 'open' |
From @lizmat
Which would be me. And as far as I recall atm, that was in response to making: $ 6 'dd "foo" ~ any(1,3,5) ~ "bar"' work. If that shouldn’t work, or work differently, it can be ripped out / replaced. If that should work, then we need to look at fixing -put-.
FWIW, I would also expect it to junct. |
From @zoffixznetOn Sat, 09 Dec 2017 13:19:23 -0800, elizabeth wrote:
IMO it should work, considering you can't nqp::unbox_n/nqp::unbox_i Junctions either, yet we don't have Junction-related explosions with numeric stuff. I also found another issue: IO::Handle.print/put infiniloop in dispatch when given a Junction.
I started a fix down that path, but it kinda looks gross and dirty. Similar thing would be needed Is there a better way? Here's my thing: 2017.11.50 zoffix@VirtualBox~/CPANPRC/rakudo (master)$ gd Inline Patchdiff --git a/src/core/IO/Handle.pm b/src/core/IO/Handle.pm
index 55ff911..0303047 100644
--- a/src/core/IO/Handle.pm
+++ b/src/core/IO/Handle.pm
@@ -652,6 +652,11 @@ my class IO::Handle {
multi method print(IO::Handle:D: **@list is raw --> True) { # is raw gives List, which is cheaper
self.print(@list.join);
}
+ multi method print(IO::Handle:D: Junction \j --> True) {
+ # junct the Junction. Without this candidate, we'd go through the
+ # **@list slurpy candidate and dispatch infiniloop.
+ -> Any \el { self.print: el }(j)
+ }
proto method put(|) {*}
multi method put(IO::Handle:D: Str:D \x --> True) {
@@ -662,6 +667,11 @@ my class IO::Handle {
multi method put(IO::Handle:D: **@list is raw --> True) { # is raw gives List, which is cheaper
self.put(@list.join);
}
+ multi method put(IO::Handle:D: Junction \j --> True) {
+ # junct the Junction. Without this candidate, we'd go through the
+ # **@list slurpy candidate and dispatch infiniloop.
+ -> Any \el { self.put: el }(j)
+ }
multi method say(IO::Handle:D: Str:D $x --> True) {
$!decoder or die X::IO::BinaryMode.new(:trying<say>); |
From @zoffixznetOn Sat, 09 Dec 2017 15:26:25 -0800, cpan@zoffix.com wrote:
Thank you for the report. lizmat++ fixed this. Fix: rakudo/rakudo@8155c4b885 |
@zoffixznet - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#132549 (status was 'resolved')
Searchable as RT132549$
The text was updated successfully, but these errors were encountered: