Hi,

There are a handful of failing tests in languages/perl6/ that fail with
the following error:

Object must be created by a class.

I've done some digging into what's going on. Basically, the Perl 6
compiler generates code that makes an Undef PMC, for a new lexical, and
then assigns to it. That calls the assign_pmc vtable method on the Undef
PMC, which as its first step will morph itself to the type of the thing
that is being assigned to it.

The morph vtable method takes an INTVAL parameter, which is the type to
morph to. It re-uses the current chunk of memory, sets it up for the type
of PMC we're morphing to and calls init. That works just fine for PMC
types, which have a type ID. For high level objects, however, it doesn't
work. You end up trying to instantiate an Object PMC, which is not allowed
other than through the Class PMC, thus the error. You wouldn't want to
make that work, or you end up with objects associated with no class.

Basically, if morph should work with PDD15 types - which I guess it needs
to - then we need to be able to pass it something other than a type ID. An
instance of Class or PMCProxy would make sense - you call new on that and
it instantiates a new object set up correctly for that class. That's not
enough though - we need to get "new" to re-use the memory location we want
it to. I guess we could give "new" a reuse optional parameter, where you
pass in the PMC that should be replaced with what is instantiated. Maybe
(hopefully) someone has a better idea.

Hope this makes sense,

Jonathan

Reply via email to