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

B::Deparse breaks constant overloading #14313

Open
p5pRT opened this issue Dec 8, 2014 · 3 comments
Open

B::Deparse breaks constant overloading #14313

p5pRT opened this issue Dec 8, 2014 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Dec 8, 2014

Migrated from rt.perl.org#123385 (status was 'open')

Searchable as RT123385$

@p5pRT
Copy link
Author

p5pRT commented Dec 8, 2014

From @cpansprout

This​:

  BEGIN {
  overload​::constant qr => sub {
  my ($raw, $cooked, $type) = @​_;
  return $cooked unless defined $​::CONST_QR_CLASS;
  if ($type =~ /qq?/) {
  return bless \$cooked, $​::CONST_QR_CLASS;
  } else {
  return $cooked;
  }
  };
  }

deparses as​:

  sub BEGIN {
  overload​::constant('qr', sub {
  my($raw, $cooked, $type) = @​_;
  return $cooked unless defined $main​::CONST_QR_CLASS;
  if ($type =~ /qq?/) {
  return bless(\$cooked, $main​::CONST_QR_CLASS);
  }
  else {
  return $cooked;
  }
  }
  );
  }
  BEGIN {
  $^H{'qr'} = 'CODE(0x7f87728ce238)';
  }

That assignment to %^H completely breaks qr overloading for the rest of the scope. Regular expressions just won’t compile.

Is it necessary to deparse %^H like that? I can understand doing that if there is no other way to reproduce the hints. But the hints will not have changed without some BEGIN block or ‘use’ statement. And those are now (supposedly) deparsed in the right spot.

So it is perhaps time to retire the extra deparsing of %^H?

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Dec 13, 2014

From @cpansprout

On Sun Dec 07 20​:18​:08 2014, sprout wrote​:

This​:

BEGIN {
overload​::constant qr => sub {
my ($raw, $cooked, $type) = @​_;
return $cooked unless defined $​::CONST_QR_CLASS;
if ($type =~ /qq?/) {
return bless \$cooked, $​::CONST_QR_CLASS;
} else {
return $cooked;
}
};
}

deparses as​:

sub BEGIN {
overload​::constant('qr', sub {
my($raw, $cooked, $type) = @​_;
return $cooked unless defined $main​::CONST_QR_CLASS;
if ($type =~ /qq?/) {
return bless(\$cooked, $main​::CONST_QR_CLASS);
}
else {
return $cooked;
}
}
);
}
BEGIN {
$^H{'qr'} = 'CODE(0x7f87728ce238)';
}

Applies to charnames, too​:

use charnames ('​:full');
BEGIN {
  $^H{'charnames'} = 'CODE(0x7ff42ba06340)';
  $^H{'charnames_full'} = '1';
  $^H{'charnames_inverse_ords'} = 'HASH(0x7ff42bc957c0)';
  $^H{'charnames_loose'} = '0';
  $^H{'charnames_name_aliases'} = 'HASH(0x7ff42bc95778)';
  $^H{'charnames_ord_aliases'} = 'HASH(0x7ff42bc95730)';
  $^H{'charnames_scripts'} = '';
  $^H{'charnames_short'} = '0';
  $^H{'charnames_stringified_inverse_ords'} = '';
  $^H{'charnames_stringified_names'} = '';
  $^H{'charnames_stringified_ords'} = '';
}

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Dec 13, 2014

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

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

No branches or pull requests

2 participants