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

Subclass of Date + role = attribute default fail #5000

Closed
p6rt opened this issue Jan 5, 2016 · 6 comments
Closed

Subclass of Date + role = attribute default fail #5000

p6rt opened this issue Jan 5, 2016 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Jan 5, 2016

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

Searchable as RT127170$

@p6rt
Copy link
Author

p6rt commented Jan 5, 2016

From @japhb

Mixing a role into a subclass of Date loses defaults for the role's attributes​:

08​:44 < japhb> m​: role Foo { has $.s = 42; has @​.a = 7, 8, 9; }; class
Bar does Foo { }; class BarDate is Date does Foo { }; dd Bar.new.a; dd
BarDate.today.a;
08​:44 <+camelia> rakudo-moar 75c6b9​: OUTPUT«Array @​!a = [7, 8,
9]␤Array @​!a = []␤»

This worked fine as of a couple weeks ago ... I'm guessing one of the
Temporal refactorings/optimizations broke this case?

FWIW, I noticed this because I created a "BusinessDateish" role for
keeping track of business quarters, holidays, etc., and then created
BusinessDate and BusinessDateTime as subclasses of Date and DateTime
with BusinessDateish mixed in.

@p6rt
Copy link
Author

p6rt commented Jan 6, 2016

From @lizmat

On 05 Jan 2016, at 17​:51, Geoffrey Broadwell (via RT) <perl6-bugs-followup@​perl.org> wrote​:

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

Mixing a role into a subclass of Date loses defaults for the role's attributes​:

08​:44 < japhb> m​: role Foo { has $.s = 42; has @​.a = 7, 8, 9; }; class
Bar does Foo { }; class BarDate is Date does Foo { }; dd Bar.new.a; dd
BarDate.today.a;
08​:44 <+camelia> rakudo-moar 75c6b9​: OUTPUT«Array @​!a = [7, 8,
9]␤Array @​!a = []␤»

This worked fine as of a couple weeks ago ... I'm guessing one of the
Temporal refactorings/optimizations broke this case?

FWIW, I noticed this because I created a "BusinessDateish" role for
keeping track of business quarters, holidays, etc., and then created
BusinessDate and BusinessDateTime as subclasses of Date and DateTime
with BusinessDateish mixed in.

I think this is happening because I gave Date/DateTime their own new / BUILD combo, so it’s not going through the default new process, thereby bypassing the automatic default handling for mixed in attributes. Which is a large part of the speedup of Date/DateTime.

Looking at ways to create a different code path for Date only, and subclassed Date, thereby restoring the above behaviour, while keeping most of the speed increase for the most common cases.

Liz

@p6rt
Copy link
Author

p6rt commented Jan 6, 2016

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

@p6rt
Copy link
Author

p6rt commented Jan 6, 2016

From @lizmat

On 05 Jan 2016, at 17​:51, Geoffrey Broadwell (via RT) <perl6-bugs-followup@​perl.org> wrote​:

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

Mixing a role into a subclass of Date loses defaults for the role's attributes​:

08​:44 < japhb> m​: role Foo { has $.s = 42; has @​.a = 7, 8, 9; }; class
Bar does Foo { }; class BarDate is Date does Foo { }; dd Bar.new.a; dd
BarDate.today.a;
08​:44 <+camelia> rakudo-moar 75c6b9​: OUTPUT«Array @​!a = [7, 8,
9]␤Array @​!a = []␤»

This worked fine as of a couple weeks ago ... I'm guessing one of the
Temporal refactorings/optimizations broke this case?

FWIW, I noticed this because I created a "BusinessDateish" role for
keeping track of business quarters, holidays, etc., and then created
BusinessDate and BusinessDateTime as subclasses of Date and DateTime
with BusinessDateish mixed in.

Fixed with fec0619 , tests added with 5e7d2ad , can be closed.

Liz

@p6rt
Copy link
Author

p6rt commented Jan 9, 2016

From @usev6

On Wed Jan 06 06​:05​:47 2016, elizabeth wrote​:
[...]

Fixed with fec0619 , tests added with 5e7d2ad , can be closed.

Thanks! I'm closing this ticket as 'resolved'.

@p6rt
Copy link
Author

p6rt commented Jan 9, 2016

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

@p6rt p6rt closed this as completed Jan 9, 2016
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