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

Cannot call a routine using 'foo' syntax when a module 'foo' is declared in Rakudo #2962

Closed
p6rt opened this issue Nov 5, 2012 · 8 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Nov 5, 2012

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

Searchable as RT115608$

@p6rt
Copy link
Author

p6rt commented Nov 5, 2012

From @masak

<diakopter> r​: module foo; macro foo() { }; foo; foo(); # foo works;
foo() doesn't
<p6eval> rakudo 64208d​: OUTPUT«invoke() not implemented in class
'foo'␤ in block at /tmp/JEyQXBbqaU​:1␤␤»
<masak> diakopter​: both should work.
<diakopter> masak​: both should invoke macro foo? or one should invoke
macro foo and the other invoke class foo (like it's doing)?
<masak> diakopter​: both should invoke macro foo, IMO.
<masak> r​: module foo; sub foo() { say "OH HAI" }; foo; foo()
<p6eval> rakudo 64208d​: OUTPUT«invoke() not implemented in class
'foo'␤ in block at /tmp/n8jWXMP4lX​:1␤␤»
<masak> same there; really unrelated to macros, I think.
<diakopter> oh
* masak submits diakopter's rakudobug

@p6rt
Copy link
Author

p6rt commented Nov 5, 2012

From @masak

<jnthn> module foo; sub foo() { say "OH HAI" }; foo; foo()
<jnthn> In this one, foo() parses as a coercion.
<masak> jnthn​: oh!
* masak adds that to the appropriate rakudobug
<jnthn> Anyway, it's right it doesn't call the sub. Just an LTA error I
guess...though I ain't immediately sure what to do with it...

@p6rt
Copy link
Author

p6rt commented Nov 5, 2012

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

@p6rt
Copy link
Author

p6rt commented Mar 11, 2015

From @usev6

There are no error messages anymore​:

$ perl6 -e 'module foo; macro foo() { }; foo; foo();'

$ perl6 -e 'module foo; sub foo() { say "OH HAI" }; foo; foo()'

As I understand it, both 'foo' and 'foo()' are invoking the class. (It is possible to call the sub with '&foo()', though.)

$ perl6 -e 'module foo; sub foo() { say "OH HAI" }; say foo; say foo()'
(foo)
(foo(Any))

In the light of jnthn's comments, this looks right to me. So, is this closable with tests or did I misunderstand?

1 similar comment
@p6rt
Copy link
Author

p6rt commented Mar 11, 2015

From @usev6

There are no error messages anymore​:

$ perl6 -e 'module foo; macro foo() { }; foo; foo();'

$ perl6 -e 'module foo; sub foo() { say "OH HAI" }; foo; foo()'

As I understand it, both 'foo' and 'foo()' are invoking the class. (It is possible to call the sub with '&foo()', though.)

$ perl6 -e 'module foo; sub foo() { say "OH HAI" }; say foo; say foo()'
(foo)
(foo(Any))

In the light of jnthn's comments, this looks right to me. So, is this closable with tests or did I misunderstand?

@p6rt
Copy link
Author

p6rt commented Oct 13, 2015

From @skids

I was looking into making some worries about failing to shadow
constants and classes (when you might expect to) for this.
While trying to write a $*W.describe_symbol to turn a symbol
back into a user-friendly non-modifier like "class","role",
"variable","constant", etc. I was having a hard time figuring
out where the information about what scope/kind of symbol
one was dealing with was stored.

Turns out it is not, as far as I can see, and so we have this​:

(07​:08​:46 PM) skids​: m​: sub a (\b) { EVAL "sub b() \{ 42.say }; b().say;" }; a(2); a(Str) # found while tryng to make worries for RT#​115608
(07​:08​:47 PM) camelia​: rakudo-moar ca25b0​: OUTPUT«42␤True␤(Str(Any))␤»
(07​:09​:53 PM) skids​: Nothing seems to store whether a !is​::concrete was syntactically a constant.

...which might be a bit more of an interpreterish semantic than we want?

@p6rt
Copy link
Author

p6rt commented Nov 26, 2015

From @jnthn

On Mon Nov 05 09​:39​:33 2012, masak wrote​:

<jnthn> module foo; sub foo() { say "OH HAI" }; foo; foo()
<jnthn> In this one, foo() parses as a coercion.
<masak> jnthn​: oh!
* masak adds that to the appropriate rakudobug
<jnthn> Anyway, it's right it doesn't call the sub. Just an LTA error I
guess...though I ain't immediately sure what to do with it...

It's ruled that forming a coercion type is the correct behavior​:

http://irclog.perlgeek.de/perl6/2015-11-26#i_11605891

And current Rakudo does indeed form one. Tests covering this behavior in S02-names-vars/names.t.

@p6rt
Copy link
Author

p6rt commented Nov 26, 2015

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

@p6rt p6rt closed this as completed Nov 26, 2015
@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