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

Rakudo erroneously parses some optional-parameter question marks as twigils #2081

Closed
p6rt opened this issue Aug 20, 2010 · 9 comments
Closed

Comments

@p6rt
Copy link

p6rt commented Aug 20, 2010

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

Searchable as RT77338$

@p6rt
Copy link
Author

p6rt commented Aug 20, 2010

From @masak

<masak> rakudo​: role A[​::T?] {}; class B does A[] {}; say "alive"
<p6eval> rakudo 7b0031​: OUTPUT«===SORRY!===␤Unable to parse
def_module_name, couldn't find final ']' at line 22␤»
* masak submits rakudobug
<masak> the Lion roars again!
<TimToady> std​: role A[​::T?] {}; class B does A[] {}; say "alive"
<p6eval> std 32075​: OUTPUT«�[31m===�[0mSORRY!�[31m===�[0m␤Unable to
parse generic role [...]
<masak> ...or not.
<TimToady> I don't think that syntax is legal
<masak> I'm starting to suspect you're right...
<TimToady> std​: role A[​::T $?] {}; class B does A[] {}; say "alive"
<p6eval> std 32075​: OUTPUT«ok 00​:01 119m␤»
<masak> oh right.
<TimToady> you can't put ? on a type constraint, which :​:T is parsed as
<masak> makes sense.
<masak> rakudo​: role A[​::T $?] {}; class B does A[] {}; say "alive"
<p6eval> rakudo 7b0031​: OUTPUT«===SORRY!===␤In signature parameter,
'$?', it is illegal to use '?' twigil [...]
* masak submits this other bug instead :)
<TimToady> heh, STD's twigils require a following \w
<masak> rakudo​: role A[​::T $?] {}
<p6eval> rakudo 7b0031​: OUTPUT«===SORRY!===␤In signature parameter,
'$?', it is illegal to use '?' twigil [...]
<masak> rakudo​: sub foo(​::T $?) {}
<p6eval> rakudo 7b0031​: OUTPUT«===SORRY!===␤In signature parameter,
'$?', it is illegal to use '?' twigil [...]
<TimToady> std​: role A[​::T $ ?] {}; class B does A[] {}; say "alive"
<masak> I agree; it's not a twigil unless there's something coming after it :)

@p6rt
Copy link
Author

p6rt commented Nov 13, 2011

From @coke

No change on original error in a recent-vintage nom.
--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Nov 13, 2011

@coke - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jan 15, 2014

From @coke

Removing testneeded tag - this is still erroring.

@p6rt
Copy link
Author

p6rt commented Oct 13, 2014

From @usev6

This looks good to me now​:

$ perl6-m -e 'sub foo(​::T $?) {}; say "alive"'
alive

$ perl6-m -e 'role A[​::T $?] {}; class B does A[] {}; say "alive"'
alive

The following dies, but that's okay (from the IRC log above​: "<TimToady> you can't put ? on a type constraint, which :​:T is parsed as").

$ perl6-m -e 'role A[​::T?] {}; class B does A[] {}; say "alive"'
===SORRY!=== Error while compiling -e
Unable to parse expression in generic role; couldn't find final ']'
at -e​:1
------> role A[​::T⏏?] {}; class B does A[] {}; say "alive"
  expecting any of​:
  statement list
  prefix or term
  prefix or meta-prefix
  generic role
  formal parameter
  constraint

I'll add those three as tests and if nobody objects I'll close this ticket.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Oct 13, 2014

From @usev6

This looks good to me now​:

$ perl6-m -e 'sub foo(​::T $?) {}; say "alive"'
alive

$ perl6-m -e 'role A[​::T $?] {}; class B does A[] {}; say "alive"'
alive

The following dies, but that's okay (from the IRC log above​: "<TimToady> you can't put ? on a type constraint, which :​:T is parsed as").

$ perl6-m -e 'role A[​::T?] {}; class B does A[] {}; say "alive"'
===SORRY!=== Error while compiling -e
Unable to parse expression in generic role; couldn't find final ']'
at -e​:1
------> role A[​::T⏏?] {}; class B does A[] {}; say "alive"
  expecting any of​:
  statement list
  prefix or term
  prefix or meta-prefix
  generic role
  formal parameter
  constraint

I'll add those three as tests and if nobody objects I'll close this ticket.

@p6rt
Copy link
Author

p6rt commented Oct 13, 2014

From @usev6

The tests are in S06-signature/optional.t and S14-roles/parameterized-basic.t, respectively. They were added with the following commit​: Raku/roast@2b3bee5223

1 similar comment
@p6rt
Copy link
Author

p6rt commented Oct 13, 2014

From @usev6

The tests are in S06-signature/optional.t and S14-roles/parameterized-basic.t, respectively. They were added with the following commit​: Raku/roast@2b3bee5223

@p6rt
Copy link
Author

p6rt commented Oct 13, 2014

@usev6 - 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