You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Should a methodlike Signature ACCEPT extra named parameters?
# First, this is at least an LTA error but arguably should be True
bri@atlas:~/NetSight/pm6$ perl6 -e 'say so (1,2) ~~ :($a: $b)'
Lexical with name 'self' does not exist in this frame
in block <unit> at -e:1
# So just to establish this workaround works first...
bri@atlas:~/NetSight/pm6$ perl6 -e 'say so (1,2) ~~ :(\self: $b)'
True
# ...and now we see that a methodlike signature rejects extra nameds:
bri@atlas:~/NetSight/pm6$ perl6 -e 'say so (1,2,:a) ~~ :(\self: $b)'
False
This has sort of been swept under the rug by making it difficult to
make a signature literal with an invocant.
$ perl6 -e 'say so (1,2) ~~ :(\self: $b)'
===SORRY!=== Error while compiling -e
Can only use the : invocant marker in the signature for a method
at -e:1
------> say so (1,2) ~~ :(\self: $b⏏)
expecting any of:
constraint
There may eventually be a reason to do that, but for now it keeps anyone from
relying on the behavior there.
In the meantime we've made method signatures show the %*_
$ perl6 -e 'class foo { method bar (Any: $b) { } }; my $s = foo.^find_method("bar").signature; $s .= clone; $s.perl.say; say so (1, 2, :a) ~~ $s'
:($: $b, *%_)
True
Perhaps were we to ever allow methodish signature literals, we could say
it is the "method" declaration (or something in ClassHOW's handling of them,
really) that adds the *%_, and one has to add it explicitly in a :()
Migrated from rt.perl.org#125438 (status was 'new')
Searchable as RT125438$
The text was updated successfully, but these errors were encountered: