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

Missing serialize REPR function for REPR SCRef | When using a class using a trait that modify metamodel #5254

Closed
p6rt opened this issue Apr 22, 2016 · 7 comments

Comments

@p6rt
Copy link

p6rt commented Apr 22, 2016

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

Searchable as RT127959$

@p6rt
Copy link
Author

p6rt commented Apr 22, 2016

From pierre.vigier@gmail.com

Hi

Basically, i have a trait that add a method to a class if applied to an attribute
it's working well
however, if i try to 'use' a class that uses that trait, i have a strange error​:
Missing serialize REPR function for REPR SCRef

To show case the issue, here is a dummy module, that export a trait "mytrait".
That trait if applied to any attribute of a class, will add a new method nn to the class that returns 'nn'.
(the original module is AttrX​::Lazy, just wanted to trimdown the code base)

file mytraitmodule.pm6 contains that trait

you can see that tiny trait in action with the following​:

PERL6LIB=$PWD perl6 -e 'use mytraitmodule; class Foo { has $!att is mytrait; }; say Foo.new().nn()' [22​:18​:23]
nn

The trait is working fine.

Now, if i create a class in a separate file, that does the same thing, and load the class, for the class see file myclass.pm6
and i just try to use that new class, with a simple code like​:

PERL6LIB=$PWD perl6 -e 'use myclass;' [22​:18​:12]
===SORRY!===
Missing serialize REPR function for REPR SCRef

You see the issue, really strange, the trait is working by itself, but it's impossible to load a class that uses that trait

RabidGravy on IRC told me to add a no precompilation statement on top of the file having the role to temporary solve the issue, and i can confirm it is working.

Content of the files​:
myclass.pm6​:


unit class myclass;
use mytraitmodule;

has $!bar is mytrait;


mytraitmodule.pm6​:


unit module mytraitmodule;
my role rrHOW {
  method compose(Mu \type) {
  type.^add_method('nn', method (Mu​:D​:) { return 'nn' ; } );
  callsame;
  }
}

multi trait_mod​:<is>(Attribute​:D $attr, :$mytrait! ) is export {
  $attr.package.HOW does rrHOW;
}


Pierre

@p6rt
Copy link
Author

p6rt commented Apr 26, 2016

From @LLFourn

This is yet another compile time closure serialisation bug. I made a list
of all of them I could find​:

https://rt.perl.org/Public/Bug/Display.html?id=125634
<https://rt.perl.org/Public/Bug/Display.html?id=126818>
https://rt.perl.org/Public/Bug/Display.html?id=126818
https://rt.perl.org/Public/Bug/Display.html?id=127034
https://rt.perl.org/Public/Bug/Display.html?id=127112
<https://rt.perl.org/Public/Bug/Display.html?id=127858>
https://rt.perl.org/Public/Bug/Display.html?id=127858
<https://rt.perl.org/Public/Bug/Display.html?id=127860>
https://rt.perl.org/Public/Bug/Display.html?id=127860
https://rt.perl.org/Public/Bug/Display.html?id=127959

and added this one to the list :)

On Sun, Apr 24, 2016 at 5​:02 AM Pierre VIGIER <perl6-bugs-followup@​perl.org>
wrote​:

# New Ticket Created by Pierre VIGIER
# Please include the string​: [perl #​127959]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127959 >

Hi

Basically, i have a trait that add a method to a class if applied to an
attribute
it's working well
however, if i try to 'use' a class that uses that trait, i have a strange
error​:
Missing serialize REPR function for REPR SCRef

To show case the issue, here is a dummy module, that export a trait
"mytrait".
That trait if applied to any attribute of a class, will add a new method
nn to the class that returns 'nn'.
(the original module is AttrX​::Lazy, just wanted to trimdown the code base)

file mytraitmodule.pm6 contains that trait

you can see that tiny trait in action with the following​:

PERL6LIB=$PWD perl6 -e 'use mytraitmodule; class Foo { has $!att is
mytrait; }; say Foo.new().nn()' [22​:18​:23]
nn

The trait is working fine.

Now, if i create a class in a separate file, that does the same thing, and
load the class, for the class see file myclass.pm6
and i just try to use that new class, with a simple code like​:

PERL6LIB=$PWD perl6 -e 'use myclass;'
[22​:18​:12]
===SORRY!===
Missing serialize REPR function for REPR SCRef

You see the issue, really strange, the trait is working by itself, but
it's impossible to load a class that uses that trait

RabidGravy on IRC told me to add a no precompilation statement on top of
the file having the role to temporary solve the issue, and i can confirm it
is working.

Content of the files​:
myclass.pm6​:
--------------------
unit class myclass;
use mytraitmodule;

has $!bar is mytrait;
--------------------

mytraitmodule.pm6​:
--------------------
unit module mytraitmodule;
my role rrHOW {
method compose(Mu \type) {
type.^add_method('nn', method (Mu​:D​:) { return 'nn' ; } );
callsame;
}
}

multi trait_mod​:<is>(Attribute​:D $attr, :$mytrait! ) is export {
$attr.package.HOW does rrHOW;
}
--------------------

Pierre

@p6rt
Copy link
Author

p6rt commented Apr 26, 2016

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

@p6rt
Copy link
Author

p6rt commented Apr 28, 2017

From pierre.vigier@gmail.com

I'm not sure when it got fixed, but the same code now is working without any issues, should we close the ticket?

On Tue, 26 Apr 2016 06​:20​:45 -0700, lloyd.fourn@​gmail.com wrote​:

This is yet another compile time closure serialisation bug. I made a
list
of all of them I could find​:

https://rt.perl.org/Public/Bug/Display.html?id=125634
<https://rt.perl.org/Public/Bug/Display.html?id=126818>
https://rt.perl.org/Public/Bug/Display.html?id=126818
https://rt.perl.org/Public/Bug/Display.html?id=127034
https://rt.perl.org/Public/Bug/Display.html?id=127112
<https://rt.perl.org/Public/Bug/Display.html?id=127858>
https://rt.perl.org/Public/Bug/Display.html?id=127858
<https://rt.perl.org/Public/Bug/Display.html?id=127860>
https://rt.perl.org/Public/Bug/Display.html?id=127860
https://rt.perl.org/Public/Bug/Display.html?id=127959

and added this one to the list :)

On Sun, Apr 24, 2016 at 5​:02 AM Pierre VIGIER <perl6-bugs-
followup@​perl.org>
wrote​:

# New Ticket Created by Pierre VIGIER
# Please include the string​: [perl #​127959]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=127959 >

Hi

Basically, i have a trait that add a method to a class if applied to
an
attribute
it's working well
however, if i try to 'use' a class that uses that trait, i have a
strange
error​:
Missing serialize REPR function for REPR SCRef

To show case the issue, here is a dummy module, that export a trait
"mytrait".
That trait if applied to any attribute of a class, will add a new
method
nn to the class that returns 'nn'.
(the original module is AttrX​::Lazy, just wanted to trimdown the code
base)

file mytraitmodule.pm6 contains that trait

you can see that tiny trait in action with the following​:

PERL6LIB=$PWD perl6 -e 'use mytraitmodule; class Foo { has $!att is
mytrait; }; say Foo.new().nn()' [22​:18​:23]
nn

The trait is working fine.

Now, if i create a class in a separate file, that does the same
thing, and
load the class, for the class see file myclass.pm6
and i just try to use that new class, with a simple code like​:

PERL6LIB=$PWD perl6 -e 'use myclass;'
[22​:18​:12]
===SORRY!===
Missing serialize REPR function for REPR SCRef

You see the issue, really strange, the trait is working by itself,
but
it's impossible to load a class that uses that trait

RabidGravy on IRC told me to add a no precompilation statement on top
of
the file having the role to temporary solve the issue, and i can
confirm it
is working.

Content of the files​:
myclass.pm6​:
--------------------
unit class myclass;
use mytraitmodule;

has $!bar is mytrait;
--------------------

mytraitmodule.pm6​:
--------------------
unit module mytraitmodule;
my role rrHOW {
method compose(Mu \type) {
type.^add_method('nn', method (Mu​:D​:) { return 'nn' ; } );
callsame;
}
}

multi trait_mod​:<is>(Attribute​:D $attr, :$mytrait! ) is export {
$attr.package.HOW does rrHOW;
}
--------------------

Pierre

@p6rt
Copy link
Author

p6rt commented Apr 29, 2017

From @zoffixznet

On Thu, 27 Apr 2017 21​:13​:34 -0700, pierre.vigier@​gmail.com wrote​:

I'm not sure when it got fixed, but the same code now is working
without any issues, should we close the ticket?

Marking this as Tests needed

@p6rt
Copy link
Author

p6rt commented Feb 2, 2018

From @zoffixznet

Tests​: Raku/roast@72f2c3984c

@p6rt
Copy link
Author

p6rt commented Feb 2, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant