Skip to content

Commit

Permalink
Catch too-late application of REPR trait.
Browse files Browse the repository at this point in the history
Fixes RT #125574.
  • Loading branch information
jnthn committed Jul 9, 2015
1 parent ed8270a commit a51ac08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Perl6/Grammar.nqp
Expand Up @@ -2064,6 +2064,9 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
symbol => $longname.name(),
);
}
if nqp::defined($*REPR) {
$*W.throw($/, ['X', 'TooLateForREPR'], type => $*PACKAGE);
}
}

# If it's not a role, or it is a role but one with no name,
Expand Down
7 changes: 7 additions & 0 deletions src/core/Exception.pm
Expand Up @@ -2010,4 +2010,11 @@ my class X::StubCode is Exception {
has $.message = 'Stub code executed';
}

my class X::TooLateForREPR is X::Comp {
has $.type;
method message() {
"Cannot change REPR of $!type.^name() now (must be set at initial declaration)";
}
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit a51ac08

Please sign in to comment.