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

regex match inside a 'given $expr { ... }' block does not set $/ #1166

Closed
p6rt opened this issue Jul 24, 2009 · 9 comments
Closed

regex match inside a 'given $expr { ... }' block does not set $/ #1166

p6rt opened this issue Jul 24, 2009 · 9 comments

Comments

@p6rt
Copy link

p6rt commented Jul 24, 2009

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

Searchable as RT67864$

@p6rt
Copy link
Author

p6rt commented Jul 24, 2009

From @moritz

20​:56 <@​moritz_> rakudo​: given 'mrGreen 5 1 23 ' { /<[a..zA..Z]>*\d/ }
20​:56 < p6eval> rakudo dd5767​: ( no output )
20​:57 <@​moritz_> rakudo​: given 'mrGreen 5 1 23 ' { /<[a..zA..Z]>*\d/ &&
say $/ }
20​:57 < p6eval> rakudo dd5767​: OUTPUT«Use of uninitialized value␤␤»

You can see that $/ is not set inside the block, which is of course less
than awesome.

Moritz

@p6rt
Copy link
Author

p6rt commented Jul 24, 2009

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S05-match/blocks.t

commit 2f97978bac871ca9d2669c4b1050ac4a8b0c523d
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Fri Jul 24 19​:38​:30 2009 +0000

  [t/spec] test for RT #​67864
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;27710 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S05-match/blocks.t b/t/spec/S05-match/blocks.t
index 5ef8f68..4210fb7 100644
--- a/t/spec/S05-match/blocks.t
+++ b/t/spec/S05-match/blocks.t
@@ -1,7 +1,7 @@
 use v6;
 use Test;
 
-plan 20;
+plan 21;
 
 =begin description
 
@@ -67,6 +67,17 @@ ok !defined($/), '$/ still undef in the outer block';
     is "$/",   'x', '... and can use $/ outside the block';
 }
 
+{
+    given '-Wall' {
+        if /\w+/ {
+            #?rakudo todo 'RT 67864'
+            ok $/ eq 'Wall', '$/ is properly set in a given { } block';
+        } else {
+            flunk 'regex did not match - $/ is properly set in a given { } block';
+        }
+    }
+}
+
 # TODO: repeat ... until, gather/take, lambdas, if/unless statement modifiers
 # TODO: move to t/spec/integration/
 

@p6rt
Copy link
Author

p6rt commented Jul 24, 2009

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

@p6rt
Copy link
Author

p6rt commented Oct 25, 2009

From coleoid@yahoo.com

given 'ick' {
  if $_ ~~ m/(i)/ {
  say "if <explicit> should say [i]" ~ (($/ eq 'i') ?? '' !! ", but says") ~ "​: [$/]"
  }
  if m/(c)/ {
  say "if <implicit> should say [c]" ~ (($/ eq 'c') ?? '' !! ", but says") ~ "​: [$/]"
  }
  when m/(k)/ {
  say "when <implicit> should say [k]" ~ (($/ eq 'k') ?? '' !! ", but says") ~ "​: [$/]"
  }
}

=begin output

if <explicit> should say [i]​: [i]
if <implicit> should say [c], but says​: [i]
when <implicit> should say [k]​: [k]

=end output

 

@p6rt
Copy link
Author

p6rt commented Mar 18, 2010

From @masak

<masak> rakudo​: $_ = 42; if $_ ~~ /\d+/ { say +$/ }
<p6eval> rakudo e4e058​: OUTPUT«42␤»
<masak> rakudo​: $_ = 42; if /\d+/ { say +$/ }
<p6eval> rakudo e4e058​: OUTPUT«Use of type object as value in numeric
context␤current instr.​: 'perl6;Perl6Exception;throw' pc 14489
(src/builtins/Seq.pir​:77)␤»
<masak> what's up with that? regression?
<jnthn> That's...odd
* masak submits rakudobug

@p6rt
Copy link
Author

p6rt commented Sep 11, 2011

From @bbkr

NOM​: still broken

bbkr​:nom bbkr$ ./perl6 -e '$_ = 42; if /\d+/ { say +$/ }'
Use of uninitialized value in numeric context
0

@p6rt
Copy link
Author

p6rt commented Jan 17, 2012

From @jnthn

On Sun Sep 11 02​:31​:39 2011, bbkr wrote​:

NOM​: still broken

bbkr​:nom bbkr$ ./perl6 -e '$_ = 42; if /\d+/ { say +$/ }'
Use of uninitialized value in numeric context
0

Works now​:

$_ = 42; if /\d+/ { say +$/ }
42

Tagging testneeded.

/jnthn

@p6rt
Copy link
Author

p6rt commented Feb 1, 2012

From @moritz

Test passes, closing ticket.

@p6rt
Copy link
Author

p6rt commented Feb 1, 2012

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

@p6rt p6rt closed this as completed Feb 1, 2012
@p6rt p6rt added the testneeded label Jan 5, 2020
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