Ticket #1640 (closed bug: fixed)

Opened 12 years ago

Last modified 11 years ago

Method names that start with '@' are not recognized.

Reported by: shockwave Owned by:
Priority: major Milestone:
Component: imcc Version: 2.3.0
Severity: high Keywords:
Cc: Language:
Patch status: Platform:

Description

Unless class methods cannot start with '@' (or just be named '@'), there is a bug in Parrot regarding that.

Regular subroutines (not methods) *can* be named '@'.

If this is the expected behavior (hopefully not), it should be marked as such in the docs.

# The following fails. Change to '*', and it succeeds.

.namespace Test?

.sub '%' :method

say 'help'

.end

.sub 'main' :main

$P0 = newclass 'Test' $P1 = new 'Test' $P1.'%'()

.end

# Error message: Method '@' not found for invocant of class 'Test'

My personal usecase of that is: In my language (as in C++), operators can be overloaded, included @. Such operator would create a method named '@', or a mangled version name something like '@m13_1', in PIR.

Change History

Changed 12 years ago by NotFound

It was a problem with imcc add_const_pmc function, it searched for a "@" namespace separator instead of the full "@@@" used.

r46684 fixes this problem, but I think that if someone wants to create a method called "@@@" we'll have a similar one.

Changed 12 years ago by NotFound

As expected, '@@@' fails:

.namespace ['Test']

.sub '@@@' :method
  say 'help'
.end

.sub 'main' :main
  $P0 = newclass 'Test'
  $P1 = new 'Test'
  $P1.'@@@'()
.end

Method '@@@' not found for invocant of class 'Test'

Changed 11 years ago by jkeenan

Is there a compelling reason why we would want methods with names beginning with @?

Thank you very much.

kid51

Changed 11 years ago by coke

On Tue, Jul 5, 2011 at 10:30 PM, Parrot <parrot-tickets@lists.parrot.org> wrote:
> #1640: Method names that start with '@' are not recognized.
> -----------------------+----------------------------------------------------
>  Reporter:  shockwave  |        Type:  bug
>   Status:  new        |    Priority:  major
> Milestone:             |   Component:  imcc
>  Version:  2.3.0      |    Severity:  high
>  Keywords:             |        Lang:
>    Patch:             |    Platform:
> -----------------------+----------------------------------------------------
>
> Comment(by jkeenan):
>
>  Is there a compelling reason why we would want methods with names
>  beginning with `@`?
>
>  Thank you very much.
>
>  kid51

To support HLLs that allow those names.

-- 
Will "Coke" Coleda

Changed 11 years ago by Felipe

I've added a fix for this issue in  https://github.com/parrot/parrot/pull/142

felipe:~/dev/parrot$ cat ../test.pir 
.namespace ['Test']

.sub '@@@' :method
  say 'help'
.end

.sub 'main' :main
  $P0 = newclass 'Test'
  $P1 = new 'Test'
  $P1.'@@@'()
.end
felipe:~/dev/parrot$ ./parrot ../test.pir 
help
felipe:~/dev/parrot$ ./parrot -o test.pbc ../test.pir 
felipe:~/dev/parrot$ ./parrot test.pbc 
help

Changed 11 years ago by Felipe

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.