Closed mgomes closed 2 years ago
I think I see why this gets put in scope: https://github.com/crystal-lang/crystal/blob/master/src/colorize.cr#L200-L202.
I didn't realize colorize
injected itself like that.
Yeah, Colorize makes things a bit weird, since the colorize
method is not directly compatible with Anyolite (unless the user modifies it specifically).
If you don't need to wrap the colorize
method, you can simply use the following snippet in your code:
module Colorize
@[Anyolite::ExcludeInstanceMethod("colorize")]
module ObjectExtensions
end
end
This should technically prevent the problematic method from being wrapped, without disabling it in Crystal.
Maybe I will put this into the Wiki soon, this seems to be a not too uncommon special case.
I removed it from my project as a workaround since I only use it in a few spots. The problem I realized is that a lot of other shards use it. So far “teeplate” and “crest” are ones I’ve found.
I’ll see if I can do anything as a workaround.
On Sep 3, 2022, at 4:19 PM, Philipp Schulz @.***> wrote:
Yeah, Colorize makes things a bit weird, since the colorize method is not directly compatible with Anyolite (unless the user modifies it specifically).
If you don't need to wrap the colorize method, you can simply use the following snippet in your code:
module Colorize @[Anyolite::ExcludeInstanceMethod("colorize")] module ObjectExtensions end end This should technically prevent the problematic method from being wrapped, without disabling it in Crystal.
Maybe I will put this into the Wiki soon, this seems to be a not too uncommon special case.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.
My apologies, I read your suggested workaround more closely and this definitely works for me. Thank you! 🙏
Fixing the problem completely (except for special cases) is not possible with Anyolite (since this is technically intended behavior), so I added a short comment on how to fix this to the wiki (https://github.com/Anyolite/anyolite/wiki/Limitations-and-solutions).
When using the "colorize" standard lib, it seems to cause a compilation error:
Reproduce
Adding:
somewhere in your project will trigger this.