X::Redeclaration Reference
Compilation error due to declaring an already declared symbol
What it is #
Routines #
Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.
method symbol #
Returns the name of the symbol that was redeclared.
method what #
Returns the kind of symbol that was redeclared. Usually symbol, but can also be routine, type etc.
method postfix #
Returns a string that is attached to the end of the error message. It usually explains the particular problem in more detail, or suggests way to fix the problem.
Examples, run three ways #
Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.
6 no-output
class X::Redeclaration does X::Comp { }Not executed: the documentation states no expected output for this example.
my $x; my $x;
Not executed: the documentation states no expected output for this example.
Redeclaration of symbol $x
Not executed: the documentation states no expected output for this example.
sub f() { }
sub f() { }Not executed: the documentation states no expected output for this example.
Redeclaration of routine f
Not executed: the documentation states no expected output for this example.
my $x;
sub f() {
my $x; # not a redeclaration,
# because it's in an inner scope
sub f() { }; # same
}Not executed: the documentation states no expected output for this example.