abelsiqueira / BestieTemplate.jl

Template for Julia Programming Language packages using the copier engine.
http://abelsiqueira.com/BestieTemplate.jl/
Mozilla Public License 2.0
38 stars 9 forks source link

Remove type piracy of Base.copy #404

Closed oxinabox closed 1 month ago

oxinabox commented 1 month ago

There was type piracy of Base.copy, because it was overloaded without any of the types belonging to this package. This can cause spooky action at a distance -- just loading this package changes what Base.copy does even if you don't load the module directly. To be precise it turned what used to be a error into an unexpected behavior. This is misdemeanor type piracy. This is thus very unlikely to have actually caused anyone problems. But still it is poor code form.

Fortunately the code has already been written to refer to Copier.copy in the place it is used. Which in this case previously resolved to Base.copy which was imported by default (check @which Copier.copy). And the Copier module doesn't use Base.copy already, so we can just rmove the Base. and it will shadow the name. Some people find shadowing spooky. The alternative is to give it a different name. Or pass a type that you own to it.)

Related issues

There is no related issue.

Checklist

(I don't think this needs a changelog entry, since it should be invisible to errors unless they were hitting this very unlikely bug)

codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (b29b69b) to head (d105db5).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #404 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 4 4 Lines 81 81 ========================================= Hits 81 81 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

abelsiqueira commented 1 month ago

Big miss on our part. I am fine shadowing it, Copier should never export copy et al., so I think that won't bother anyone.

abelsiqueira commented 1 month ago

@allcontributors please add @oxinabox for code, bug, idea

allcontributors[bot] commented 1 month ago

@abelsiqueira

I've put up a pull request to add @oxinabox! :tada: