MooseX:...onflict(3)

πŸ“¦
version 0.01 Β· 2 versions
, in fedora 43

πŸ’– NAME πŸ’–

okay bestie, so MooseX::Role::WarnOnConflict is the role thing that yells at you when a class stomps all over a role's methods without, like, officially saying it's excluding them. it's giving "hey. hey. i saw that." 🫢


✨ VERSION ✨

this is version 0.01 β€” babiest of versions, but she works πŸ’…


🌸 SYNOPSIS 🌸

so this code right here? it will warn at composition time, no cap:

{
    package My::Role;
    use MooseX::Role::WarnOnConflict;
    sub conflict {}
}
{
    package My::Class;
    use Moose;
    with 'My::Role';
    sub conflict {}
}

and the error message you get is like, similar to the following:

The class My::Class has implicitly overridden the method (conflict) from
role My::Role ...

😭 the class really said "i'm the main character now" and took over conflict.

to fix it, you gotta explicitly exclude that 'conflict' method β€” be upfront about it, bestie:

{
    package My::Class;
    use Moose;
    with 'My::Role' => { -excludes => [ 'conflict' ] };
    sub conflict {}
}

and heads up 🚨 β€” aliasing a role method to a method that already exists will also warn. the vibes get messy:

{
    package My::Class;
    use Moose;
    with 'My::Role' => {
        -excludes => ['conflict'],
        -alias    => { conflict => 'another_method' },
    };
    sub conflict       { }
    sub another_method { }
}

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, bestie. when you're using Moose::Role, a class that provides a method the role also provides will just… silently override it. no warning, no nothing. just silence πŸ’€

and that silence is exactly the problem, because it can cause strange, hard-to-debug errors when the role's methods are not called. you'll be sitting there like "why isn't my method running?? who took it??" and the answer is: nobody told you. πŸ™ˆ

the fix is literally so easy it's iconic β€” just use "MooseX::Role::WarnOnConflict" instead of "Moose::Role", and overriding a role's method becomes a composition-time warning. no more mystery, no more detective work πŸ•΅οΈβ™€οΈβœ¨

and for how to actually resolve it? see the synopsis above, i got you. πŸ‘‘


πŸŽ€ AUTHOR πŸŽ€

Curtis "Ovid" Poe <curtis.poe@gmail.com> β€” king behavior, honestly πŸ‘‘


This software is Copyright (c) 2022 by Curtis "Ovid" Poe.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

and that's the whole page, bestie!! this was written against perl v5.42.0 and stamped 2025-07-25 β€” so if you're reading this way later, just know she's been slaying since then 🌈⭐ mwah πŸ’‹

πŸ“¦ where this page comes from