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 doesn't parse @a[10] as a shaped array in a signature (but STD.pm6 does) #3218

Closed
p6rt opened this issue Aug 22, 2013 · 6 comments
Closed
Labels

Comments

@p6rt
Copy link

p6rt commented Aug 22, 2013

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

Searchable as RT119427$

@p6rt
Copy link
Author

p6rt commented Aug 22, 2013

From @masak

<timotimo> r​: sub test(@​a[10]) { say +@​a }; test((1, 2, 3, 4, 5, 6, 7,
8, 9, 10))
<camelia> rakudo e7ce6b​: OUTPUT«Constraint type check failed for
parameter '' in sub-signature of parameter @​a [...]
<timotimo> i got nothin'
<masak> timotimo​: that doesn't mean what you think it means.
<masak> r​: sub test(@​a [10]) { say "it's alive!" }; test([10])
<camelia> rakudo e7ce6b​: OUTPUT«it's alive!␤»
<TimToady> masak​: @​a[10] is supposed to mean something different than @​a [10]
<masak> TimToady​: that may be. it clearly doesn't in Rakudo ;)
<jnthn> r​: sub foo(@​a[10]) { }; foo([10])
<camelia> rakudo e7ce6b​: ( no output )
<jnthn> r​: sub foo(@​a[10]) { }; foo([9])
<camelia> rakudo e7ce6b​: OUTPUT«Constraint type check failed for
parameter '' in sub-signature of parameter @​a [...]
<jnthn> hm :)
<TimToady> it's not parsing it as a shape
<jnthn> aye, I don't think it expects to parse a shape there... :P
<jnthn> Does STD? What does it mean to parse a shape there? :)
<TimToady> I can think of two interpretation
<TimToady> one, a constraint on what you can pass in
<TimToady> secondly, one might allow @​a[$size] to bind $size to the
size, but that's a little there, and probably a bad idea
<jnthn> pobably ;)
<TimToady> STD parses it as a shape
<TimToady> in any case, the syntax @​a[] should be reserved for
shape-related declarations, not treated as a subbinding
<TimToady> anyway, if we let people write subbinding with @​a[], people
will, and then their code will break later when we require whitespace;
so better to require it now

@p6rt
Copy link
Author

p6rt commented Jan 3, 2015

From @usev6

Nowadays @​a[10] in a signature is parsed as a shaped array (and gives a fitting error message since shape declaration is NYI)​:

$ perl6 -e 'sub foo(@​a[10]) { }'
===SORRY!=== Error while compiling -e
Shape declaration is not yet implemented; please use whitespace if you meant a subsignature for unpacking
at -e​:1
------> sub foo(@​a⏏[10]) { }
  expecting any of​:
  shape declaration

Should we add a test for this error message and close this ticket or should the ticket stay open until shape declaration is implemented?

1 similar comment
@p6rt
Copy link
Author

p6rt commented Jan 3, 2015

From @usev6

Nowadays @​a[10] in a signature is parsed as a shaped array (and gives a fitting error message since shape declaration is NYI)​:

$ perl6 -e 'sub foo(@​a[10]) { }'
===SORRY!=== Error while compiling -e
Shape declaration is not yet implemented; please use whitespace if you meant a subsignature for unpacking
at -e​:1
------> sub foo(@​a⏏[10]) { }
  expecting any of​:
  shape declaration

Should we add a test for this error message and close this ticket or should the ticket stay open until shape declaration is implemented?

@p6rt
Copy link
Author

p6rt commented Jan 3, 2015

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

@p6rt
Copy link
Author

p6rt commented Nov 18, 2015

From @jnthn

On Sat Jan 03 08​:12​:50 2015, bartolin@​gmx.de wrote​:

Nowadays @​a[10] in a signature is parsed as a shaped array (and gives
a fitting error message since shape declaration is NYI)​:

$ perl6 -e 'sub foo(@​a[10]) { }'
===SORRY!=== Error while compiling -e
Shape declaration is not yet implemented; please use whitespace if you
meant a subsignature for unpacking
at -e​:1
------> sub foo(@​a⏏[10]) { }
expecting any of​:
shape declaration

Should we add a test for this error message and close this ticket or
should the ticket stay open until shape declaration is implemented?

I implemented it and added tests in S06-signature/shape.t.

/jnthn

@p6rt p6rt closed this as completed Nov 20, 2015
@p6rt
Copy link
Author

p6rt commented Nov 20, 2015

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

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant