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

Parsing of statement controls changed #970

Closed
p6rt opened this issue May 4, 2009 · 5 comments
Closed

Parsing of statement controls changed #970

p6rt opened this issue May 4, 2009 · 5 comments

Comments

@p6rt
Copy link

p6rt commented May 4, 2009

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

Searchable as RT65358$

@p6rt
Copy link
Author

p6rt commented May 4, 2009

From @moritz

As the commit mail below shows the parsing of statement controls like
'try' changed. Previously 'a(try {...}, 1)' would pass two arguments to
'try' and the result to a(), now 'try' only gets the block.

Rakudo needs to track this change.

-------- Original Message --------
Subject​: r26655 - docs/Perl6/Spec
Date​: Mon, 4 May 2009 05​:36​:16 +0200
From​: pugs-commits@​feather.perl6.nl
To​: perl6-language@​perl.org

Author​: lwall
Date​: 2009-05-04 05​:36​:15 +0200 (Mon, 04 May 2009)
New Revision​: 26655

Modified​:
  docs/Perl6/Spec/S04-control.pod
Log​:
[S04] clarify parsing of statement controls

Modified​: docs/Perl6/Spec/S04-control.pod

--- docs/Perl6/Spec/S04-control.pod 2009-05-04 03​:14​:22 UTC (rev 26654)
+++ docs/Perl6/Spec/S04-control.pod 2009-05-04 03​:36​:15 UTC (rev 26655)
@​@​ -12,8 +12,8 @​@​

  Maintainer​: Larry Wall <larry@​wall.org>
  Date​: 19 Aug 2004
- Last Modified​: 19 Apr 2009
- Version​: 76
+ Last Modified​: 3 May 2009
+ Version​: 77

This document summarizes Apocalypse 4, which covers the block and
statement syntax of Perl.
@​@​ -695,6 +695,29 @​@​
For purposes of flow control, none of these forms are considered loops,
but they may easily be applied to a normal loop.

+Note that any construct in the statement_prefix category defines
+special syntax. If followed by a block it does not parse as a
+list operator or even as a prefix unary; it will never look for any
+additional expression following the block. In particular,
+
+ foo( try {...}, 2, 3 )
+
+calls the C<foo> function with three arguments. And
+
+ do {...} + 1
+
+add 1 to the result of the do block. On the other hand, if a
+statement_control is followed by a non-block statement, all nested
+blockless statement_controls will terminate at the same statement
+ending​:
+
+ do do do foo(); bar 43;
+
+is parsed as​:
+
+ do { do { do { foo(); }}}; bar(43);
+
+
=head1 Switch statements
X<given>X<when>X<switch>X<case>X<default>

@p6rt
Copy link
Author

p6rt commented Oct 11, 2009

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S04-statements/try.t

commit ef7cd1378cc84c1435cf6f551c4f85719be590fa
Author​: kyle <kyle@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Sun Oct 11 12​:57​:48 2009 +0000

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

Inline Patch
diff --git a/t/spec/S04-statements/try.t b/t/spec/S04-statements/try.t
index 4ed7ef6..fcc4fe4 100644
--- a/t/spec/S04-statements/try.t
+++ b/t/spec/S04-statements/try.t
@@ -4,7 +4,7 @@ use Test;
 
 # L<S04/"Statement parsing"/"or try {...}">
 
-plan 15;
+plan *;
 
 {
     # simple try
@@ -83,4 +83,11 @@ plan 15;
         "return() inside a try{}-block should cause following exceptions to really die";
 }
 
+{
+    sub argcount { return +@_ }
+    is argcount( try { 17 }, 23, 99 ), 3, 'try gets a block, nothing more';
+}
+
+done_testing;
+
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Oct 11, 2009

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

@p6rt
Copy link
Author

p6rt commented Oct 11, 2009

From @kyleha

On Sun May 03 23​:16​:40 2009, moritz wrote​:

As the commit mail below shows the parsing of statement controls like
'try' changed. Previously 'a(try {...}, 1)' would pass two arguments to
'try' and the result to a(), now 'try' only gets the block.

I added a test for this, and it passes, so I'm resolving.

@p6rt
Copy link
Author

p6rt commented Oct 11, 2009

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

@p6rt p6rt closed this as completed Oct 11, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant