nayakgi / perl-compiler

Automatically exported from code.google.com/p/perl-compiler
Other
0 stars 0 forks source link

mro 'c3' mro::get_linear_isa ignores c3 #316

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
From: t/mro/basic_01_c3.t 

This tests the classic diamond inheritance pattern.

   <A>
  /   \
<B>   <C>
  \   /
   <D>

perlcc -r -e'package Diamond_A; sub foo {}; package Diamond_B; use base 
"Diamond_A";package Diamond_C;use base "Diamond_A"; package Diamond_D;use base 
("Diamond_B", "Diamond_C");use mro "c3"; package main; my $order = 
mro::get_linear_isa("Diamond_D"); print $order->[3] eq "Diamond_A" ? "ok" : 
"not ok"; print "\n"'
not ok

If you dump the output of get_linear_isa, it should be:

$VAR1 = [
          'Diamond_D',
          'Diamond_B',
          'Diamond_C',
          'Diamond_A'
        ];

Instead under perlcc, it's:

$>perlcc -r -e'package Diamond_A;sub hello { "Diamond_A::hello" }; package 
Diamond_B;use base "Diamond_A";package Diamond_C;use base "Diamond_A";sub hello 
{ "Diamond_C::hello" } package Diamond_D;use base ("Diamond_B", 
"Diamond_C");use mro "c3"; package main;use Data::Dumper;print 
Data::Dumper::Dumper( mro::get_linear_isa("Diamond_D"));'
$VAR1 = [
          'Diamond_D',
          'Diamond_B',
          'Diamond_A',
          'Diamond_C'
        ];

Original issue reported on code.google.com by todd.e.rinaldo on 7 May 2014 at 4:12

GoogleCodeExporter commented 9 years ago

Original comment by reini.urban on 9 May 2014 at 3:11

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Those lines from gv_fetchmeth() are missing in -Do when compiled:

-       Looking for method isa in package Diamond_B
-       Looking for method isa in package UNIVERSAL
-       Looking for method isa in package Diamond_C
-       Looking for method isa in package UNIVERSAL
-       Looking for method isa in package Diamond_D
-       Looking for method isa in package UNIVERSAL
-       Looking for method isa in package Diamond_B
-       Looking for method isa in package UNIVERSAL

Original comment by reini.urban on 9 May 2014 at 3:46

GoogleCodeExporter commented 9 years ago
confirm that c3 is ignored: (dfs is used instead)

(gdb) p GvHV(gv_fetchpv("Diamond_B::", GV_NOTQUAL, SVt_PVHV))
0xb3dbd0
(gdb) sdump (HV*)0xb3dbd0 
..
  MRO_WHICH = "dfs" (0x81a780)
..

Original comment by reini.urban on 9 May 2014 at 3:55

GoogleCodeExporter commented 9 years ago
Fixed with 1.45_11 

commit 23f8fd860b3bda91c9a1bfae4d7f508e9645caaf
Author: Reini Urban <rurban@cpanel.net>
Date:   Fri May 9 12:26:01 2014 -0500

    C 1.45_11: support mro c3 resolution (per package)

    we missed setting mro::set_mro($package, "c3") thus only got dfs linearization
    Fixes issue 316.

Original comment by reini.urban on 9 May 2014 at 5:27

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 23f8fd860b3b.

Original comment by reini.urban on 12 May 2014 at 3:45