Ticket #2193 (new bug)

Opened 10 years ago

Last modified 10 years ago

tailcall to Class.new fails with overriden init

Reported by: NotFound Owned by:
Priority: normal Milestone:
Component: core Version: 3.7.0
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:


Looking at winxed issue 7 in github:


I've found that the problem lies in parrot, as this pure pir code shows:

.namespace ['Foo']

.sub 'init' :method :vtable
    say 'Foo.init'

.sub 'init_pmc' :method :vtable
    .param pmc value
    say 'Foo.init'

.sub hello :method
    say 'Foo.hello'

.sub attrs1
    .param pmc clazz
    say 'attrs1'
    .local pmc at
    at = clazz.'attributes'()

.sub attrs2
    .param pmc clazz
    say 'attrs2'
    .tailcall clazz.'attributes'()

.sub newinstance1
    .param pmc clazz
    say 'newinstance1'
    .local pmc instance
    instance = clazz.'new'()

.sub newinstance2
    .param pmc clazz
    say 'newinstance2'
    .tailcall clazz.'new'()

.sub main :main
    .local pmc clazz, at1, at2, instance1, instance2
    newclass clazz, ['Foo']
    addattribute clazz, 'bar'

    null at1
    at1 = attrs1(clazz)
    at1 = at1['bar']
    at1 = at1['name']
    say at1
    null instance1
    instance1 = newinstance1(clazz)

    null at2
    at2 = attrs2(clazz)
    at2 = at2['bar']
    at2 = at2['name']
    say at2
    null instance2
    instance2 = newinstance2(clazz)


Tailcall to other method in Class (attributes in this example) works, but tailcall to new fails, it gets null instead of the newly created instance.

If the class does not override the 'init' vtable, it works.

The same happens with init_pmc tailcalling new with non empty argument list.

Change History

Changed 10 years ago by NotFound

Forgot to say: I've used :method in the example because is what the code generated by winxed does, but it fails the same way withiut it.

Note: See TracTickets for help on using tickets.