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

type declared in outer scope silently overrides routine declared in inner scope #3800

Open
p6rt opened this issue May 2, 2015 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented May 2, 2015

Migrated from rt.perl.org#124442 (status was 'open')

Searchable as RT124442$

@p6rt
Copy link
Author

p6rt commented May 2, 2015

From @rjbs

This confused the heck out of me​:

  ~/code/hub/rakudo$ ./perl6 -e 'sub byte ($i) { $i } ; say byte(1)'
  Cannot invoke this object (REPR​: P6int, cs = 0)
  in block <unit> at -e​:1

I can imagine being happy with (a) a warning when I defined the sub or (b) a
better runtime error of some sort.

--
rjbs

@p6rt
Copy link
Author

p6rt commented Sep 2, 2015

From @skids

This is actually a more generic problem affecting user-created
classes as well​:

$ perl6 -e 'class b { }; { my &b; say b.WHAT, b().WHAT }'
(b)(b(Any))

...it is just that the native types have no idea what to do
when invoked and are noisier. The above results could be equally
surprizing for someone expecting &b to get called.

If there is something in the spec that says that an outer class
namespace should be considered before the inner sub namespace I
have not seen it. When the sub is scoped more inner than the class,
I would expect the sub to win all constructs where using it
is vaid to use, personally,

I would also expect the invocation to prefer a sub over a type
when both are defined in the same scope for b(), but in this
case an argument could be made either way about the bareword
(and perhaps that should die as amibiguous.)

@p6rt
Copy link
Author

p6rt commented Sep 2, 2015

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

@p6rt
Copy link
Author

p6rt commented May 6, 2016

From @smls

Looks like a bug to me as well.

Simpler example​:

  ➜ class a {}; { sub a {42}; say a }
  (a)

  ➜ class a {}; { sub a {42}; say a() }
  Method 'shortname' not found for invocant of class 'Perl6​::Metamodel​::CoercionHOW'
  in block <unit> at -e line 1 (a)

@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