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

where constraint in blockless declaration causes spurious gobbling error #5200

Closed
p6rt opened this issue Mar 26, 2016 · 8 comments
Closed

where constraint in blockless declaration causes spurious gobbling error #5200

p6rt opened this issue Mar 26, 2016 · 8 comments

Comments

@p6rt
Copy link

p6rt commented Mar 26, 2016

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

Searchable as RT127785$

@p6rt
Copy link
Author

p6rt commented Mar 26, 2016

From trey@cpan.org

Example​:

% perl6 -e 'sub MAIN ($x where { $^x > 1 } ) { say "big" }' 4
big
% perl6 -e 'sub MAIN ($x where { $^x > 1 } ) { say "big" }' 0
Usage​:
  -e '...' <x>
% perl6 -e 'unit sub MAIN ($x where { $^x > 1 } ); say "big"' 4
===SORRY!===
Expression needs parens to avoid gobbling block
at -e​:1
------> unit sub MAIN ($x where { $^x > 1 }⏏ ); say "big"
Missing block (apparently claimed by expression)
at -e​:1
------> unit sub MAIN ($x where { $^x > 1 } );⏏ say "big"

@p6rt
Copy link
Author

p6rt commented Mar 26, 2016

From @lizmat

unit sub ???

I thought that unit was only supposed to be followed by a package like declaration??

On 26 Mar 2016, at 02​:10, Trey Harris (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Trey Harris
# Please include the string​: [perl #​127785]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127785 >

Example​:

% perl6 -e 'sub MAIN ($x where { $^x > 1 } ) { say "big" }' 4
big
% perl6 -e 'sub MAIN ($x where { $^x > 1 } ) { say "big" }' 0
Usage​:
-e '...' <x>
% perl6 -e 'unit sub MAIN ($x where { $^x > 1 } ); say "big"' 4
===SORRY!===
Expression needs parens to avoid gobbling block
at -e​:1
------> unit sub MAIN ($x where { $^x > 1 }⏏ ); say "big"
Missing block (apparently claimed by expression)
at -e​:1
------> unit sub MAIN ($x where { $^x > 1 } );⏏ say "big"

@p6rt
Copy link
Author

p6rt commented Mar 26, 2016

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

@p6rt
Copy link
Author

p6rt commented Mar 28, 2016

From trey@cpan.org

No, see S06-routines.pod​:

  As with module and class declarations, a sub declared
  with the C<unit> declarator (and ending in semicolon) is allowed at the
outermost
  file scope if it is the
  first such declaration, in which case the rest of the file is the body​:

  unit sub MAIN ($directory, :$verbose, *%other, *@​filenames);
  for @​filenames { ... }

  This form is allowed only for simple subs named C<MAIN> that are
intended
  to be run from the command line.

On Sat, Mar 26, 2016 at 7​:02 AM Elizabeth Mattijsen via RT <
perl6-bugs-followup@​perl.org> wrote​:

unit sub ???

I thought that unit was only supposed to be followed by a package like
declaration??

On 26 Mar 2016, at 02​:10, Trey Harris (via RT) <
perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Trey Harris
# Please include the string​: [perl #​127785]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127785 >

Example​:

% perl6 -e 'sub MAIN ($x where { $^x > 1 } ) { say "big" }' 4
big
% perl6 -e 'sub MAIN ($x where { $^x > 1 } ) { say "big" }' 0
Usage​:
-e '...' <x>
% perl6 -e 'unit sub MAIN ($x where { $^x > 1 } ); say "big"' 4
===SORRY!===
Expression needs parens to avoid gobbling block
at -e​:1
------> unit sub MAIN ($x where { $^x > 1 }⏏ ); say "big"
Missing block (apparently claimed by expression)
at -e​:1
------> unit sub MAIN ($x where { $^x > 1 } );⏏ say "big"

@p6rt
Copy link
Author

p6rt commented Mar 28, 2016

From @lizmat

Perhaps we should disallow “unit” with -e?

On 28 Mar 2016, at 20​:18, Trey Ethan Harris <trey@​cpan.org> wrote​:

No, see S06-routines.pod​:

As with module and class declarations, a sub declared
with the C\<unit> declarator \(and ending in semicolon\) is allowed at the outermost
file scope if it is the
first such declaration, in which case the rest of the file is the body&#8203;:

    unit sub MAIN \($directory, :$verbose, \*%other, \*@&#8203;filenames\);
    for @&#8203;filenames \{ \.\.\. \}

This form is allowed only for simple subs named C\<MAIN> that are intended
to be run from the command line\.

On Sat, Mar 26, 2016 at 7​:02 AM Elizabeth Mattijsen via RT <perl6-bugs-followup@​perl.org> wrote​:
unit sub ???

I thought that unit was only supposed to be followed by a package like declaration??

On 26 Mar 2016, at 02​:10, Trey Harris (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Trey Harris
# Please include the string​: [perl #​127785]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127785 >

Example​:

% perl6 -e 'sub MAIN ($x where { $^x > 1 } ) { say "big" }' 4
big
% perl6 -e 'sub MAIN ($x where { $^x > 1 } ) { say "big" }' 0
Usage​:
-e '...' <x>
% perl6 -e 'unit sub MAIN ($x where { $^x > 1 } ); say "big"' 4
===SORRY!===
Expression needs parens to avoid gobbling block
at -e​:1
------> unit sub MAIN ($x where { $^x > 1 }⏏ ); say "big"
Missing block (apparently claimed by expression)
at -e​:1
------> unit sub MAIN ($x where { $^x > 1 } );⏏ say "big"

@p6rt
Copy link
Author

p6rt commented Mar 29, 2016

From trey@cpan.org

It's not only in -e. I just used that for my example. A file with a unit
sub MAIN exhibits the same issue.

On Mon, Mar 28, 2016, 17​:39 Elizabeth Mattijsen via RT <
perl6-bugs-followup@​perl.org> wrote​:

Perhaps we should disallow “unit” with -e?

On 28 Mar 2016, at 20​:18, Trey Ethan Harris <trey@​cpan.org> wrote​:

No, see S06-routines.pod​:

As with module and class declarations, a sub declared
with the C\<unit> declarator \(and ending in semicolon\) is allowed at

the outermost

file scope if it is the
first such declaration, in which case the rest of the file is the

body​:

    unit sub MAIN \($directory, :$verbose, \*%other, \*@&#8203;filenames\);
    for @&#8203;filenames \{ \.\.\. \}

This form is allowed only for simple subs named C\<MAIN> that are

intended

to be run from the command line\.

On Sat, Mar 26, 2016 at 7​:02 AM Elizabeth Mattijsen via RT <
perl6-bugs-followup@​perl.org> wrote​:
unit sub ???

I thought that unit was only supposed to be followed by a package like
declaration??

On 26 Mar 2016, at 02​:10, Trey Harris (via RT) <
perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Trey Harris
# Please include the string​: [perl #​127785]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127785 >

Example​:

% perl6 -e 'sub MAIN ($x where { $^x > 1 } ) { say "big" }' 4
big
% perl6 -e 'sub MAIN ($x where { $^x > 1 } ) { say "big" }' 0
Usage​:
-e '...' <x>
% perl6 -e 'unit sub MAIN ($x where { $^x > 1 } ); say "big"' 4
===SORRY!===
Expression needs parens to avoid gobbling block
at -e​:1
------> unit sub MAIN ($x where { $^x > 1 }⏏ ); say "big"
Missing block (apparently claimed by expression)
at -e​:1
------> unit sub MAIN ($x where { $^x > 1 } );⏏ say "big"

@p6rt
Copy link
Author

p6rt commented Jul 21, 2016

From @jnthn

On Fri Mar 25 18​:10​:03 2016, trey@​cpan.org wrote​:

Example​:

% perl6 -e 'sub MAIN ($x where { $^x > 1 } ) { say "big" }' 4
big
% perl6 -e 'sub MAIN ($x where { $^x > 1 } ) { say "big" }' 0
Usage​:
-e '...' <x>
% perl6 -e 'unit sub MAIN ($x where { $^x > 1 } ); say "big"' 4
===SORRY!===
Expression needs parens to avoid gobbling block
at -e​:1
------> unit sub MAIN ($x where { $^x > 1 }⏏ ); say "big"
Missing block (apparently claimed by expression)
at -e​:1
------> unit sub MAIN ($x where { $^x > 1 } );⏏ say "big"

Fixed by removing a check that I really couldn't figure out the point of, despite some time trying​:

rakudo/rakudo@86843a3fdb

No spectests cared for it either, so it's gone. Talking of spectests, I also added a couple of cover this bug, in S06-other/main-semicolon.t, so if we do re-instate such a thing some day it at least won't have this problem. :-)

@p6rt
Copy link
Author

p6rt commented Jul 21, 2016

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

@p6rt p6rt closed this as completed Jul 21, 2016
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