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

if my $match is True and False #5228

Closed
p6rt opened this issue Apr 10, 2016 · 8 comments
Closed

if my $match is True and False #5228

p6rt opened this issue Apr 10, 2016 · 8 comments

Comments

@p6rt
Copy link

p6rt commented Apr 10, 2016

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

Searchable as RT127869$

@p6rt
Copy link
Author

p6rt commented Apr 10, 2016

From martin@senfdax.de

Hi there,

following code dies in this line​:

if my $match = $r.match($meth, $uri) { die "What?!" unless $match }

this happens on both moar-2015.12 and moar-2016.03

class Abc {
  has Str $.method;
  has Regex $.path is required;

  method match (Str $method, Str $path) {
  return False if $.method ne $method;
  return $path ~~ $.path;
  }
}

my @​routes = (
  Abc.new(method => "GET", path => / ^ '/'foo $ / );
  Abc.new(method => "POST", path => / ^ '/'bar $ /);
);

sub foo($meth, $uri) {
  for @​routes -> $r {
  if my $match = $r.match($meth, $uri) { die "What?!" unless $match }
  }
}

my @​hex = ('A'..'F', 'a'..'f', 0..9).flat;
for @​hex -> $first {
  for @​hex -> $second {
  foo("POST", 'http://127.0.0.1/utf8');
  }
}

@p6rt
Copy link
Author

p6rt commented Jul 10, 2016

From @zoffixznet

Still present in 2016.06-154-g55c359e built on MoarVM version 2016.06-9-g8fc21d5

Attempted to golf it, but failed.

@p6rt
Copy link
Author

p6rt commented Jul 25, 2016

From @bduggan

I was able to reproduce it with this​:

sub match ($str, $flip) {
  return False if $flip eq "no";
  return $str ~~ rx/foo/;
}

for 0..104 {
  for "no", "yes" -> $flip {
  if my $match = match("something", $flip) {
  die "What?!" unless $match
  }
  }
}

@p6rt
Copy link
Author

p6rt commented Dec 18, 2016

From @zoffixznet

On Sun, 10 Apr 2016 07​:56​:38 -0700, martin@​senfdax.de wrote​:

Hi there,

following code dies in this line​:

if my $match = $r.match($meth, $uri) { die "What?!" unless $match }

this happens on both moar-2015.12 and moar-2016.03

class Abc {
has Str $.method;
has Regex $.path is required;

method match \(Str $method, Str $path\) \{
    return False if $\.method ne $method;
    return $path ~~ $\.path;
\}

}

my @​routes = (
Abc.new(method => "GET", path => / ^ '/'foo $ / );
Abc.new(method => "POST", path => / ^ '/'bar $ /);
);

sub foo($meth, $uri) {
for @​routes -> $r {
if my $match = $r.match($meth, $uri) { die "What?!" unless $match }
}
}

my @​hex = ('A'..'F', 'a'..'f', 0..9).flat;
for @​hex -> $first {
for @​hex -> $second {
foo("POST", 'http://127.0.0.1/utf8');
}
}

Unable to reproduce this on This is Rakudo version 2016.12-10-g7a642f8 built on MoarVM version 2016.12
implementing Perl 6.c.

@p6rt
Copy link
Author

p6rt commented Dec 18, 2016

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

@p6rt
Copy link
Author

p6rt commented Mar 10, 2018

From @dogbert17

On Sun, 18 Dec 2016 15​:36​:31 -0800, cpan@​zoffix.com wrote​:

On Sun, 10 Apr 2016 07​:56​:38 -0700, martin@​senfdax.de wrote​:

Hi there,

following code dies in this line​:

if my $match = $r.match($meth, $uri) { die "What?!" unless $match }

this happens on both moar-2015.12 and moar-2016.03

class Abc {
has Str $.method;
has Regex $.path is required;

method match (Str $method, Str $path) {
return False if $.method ne $method;
return $path ~~ $.path;
}
}

my @​routes = (
Abc.new(method => "GET", path => / ^ '/'foo $ / );
Abc.new(method => "POST", path => / ^ '/'bar $ /);
);

sub foo($meth, $uri) {
for @​routes -> $r {
if my $match = $r.match($meth, $uri) { die "What?!" unless
$match }
}
}

my @​hex = ('A'..'F', 'a'..'f', 0..9).flat;
for @​hex -> $first {
for @​hex -> $second {
foo("POST", 'http://127.0.0.1/utf8');
}
}

Unable to reproduce this on This is Rakudo version 2016.12-10-g7a642f8
built on MoarVM version 2016.12
implementing Perl 6.c.

Fixed with commit rakudo/rakudo@25e9fd7

For reference​:
Raku/nqp@2016.07-140-g2df0a06...2016.07-177-gb416158
MoarVM/MoarVM@2016.07-17-g40948f6...2016.07-24-g31eccd7

@p6rt
Copy link
Author

p6rt commented Apr 7, 2018

From @moritz

Test added in rakudo/rakudo@ee5150e424

@p6rt
Copy link
Author

p6rt commented Apr 7, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant