Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent method specialization/overwriting with kwargs gives no warnings #42207

Open
KnutAM opened this issue Sep 10, 2021 · 0 comments
Open

Comments

@KnutAM
Copy link
Contributor

KnutAM commented Sep 10, 2021

This is also shown in issue #9498, but that issue is set for 2.0. The issue here is for possible intermediate solutions to prevent bug introduction in codes caused by re-ordering of function definitions.

f1(a,b)="no extra";f1(a,b;kwargs...) = ";kwargs..."; (f1(1,1), f1(1,1,k=1))

gives (";kwargs...", ";kwargs..."). And methods(f1) gives 1 method. So this is consistent with the last definition overwriting the first. However,

f2(a,b;kwargs...) = ";kwargs..."; f2(a,b)="no extra"; (f2(1,1), f2(1,1,k=1))

gives ("no extra", ";kwargs..."). But methods(f2) still gives 1 method. Yet, it does not seem like the last definition overwrote the first. So I see two problems:

  1. The output of methods seems wrong?
  2. It seems unstable that overwriting only occurs when the kwargs version comes last, but not the other way around?

As I understood from #9498, these are not possible to solve without introducing breaking changes and will not be solved in 1.x?
However, it would still be nice to (at least untill #9498 is solved) have some warning or similar to highlight that these patterns might easily introduce bugs.

(Tested on 1.6.2 and 1.7.0-beta4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant