-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
early param count check for overloads #21673
Conversation
Wrong idea IMHO. What we need to do instead is to abolish template withX(body: typed) = body
need to work reliably. Then we can simply deprecate |
I mean the way the parameter type checking works that would still have the same problem, we need to force not fully compiled expressions to be fully compiled to check if they match concrete types (which always match better) The problem is when it is used in places the type system should easily be able to handle without tons of new constructs and complexity, which is not always the case. I wouldn't know how to reasonably define We can deal with the most common cases, like Also I don't see anything wrong with this patch in general, for calls like |
That's only true for unary/binary plus and minus, most operations that are heavily overloaded like
Not a problem, |
Thinking about it more, outside of the right-justified The Maybe there's a way to change the design of "add blocks/pragma macro defs to the end of the call" that is compatible with the existing style of overloading, maybe new types like |
The "real" problem: Put |
I really think this is fine but whatever, I'm not going to maintain this PR if no one wants it. (For the record |
closes nim-lang/RFCs#402, closes #18618 (this was adapted and improved), closes #14827, closes #19556, closes #20274 (all tested), closes #17164 (untested because implementation detail)
Store the minimum "required" parameters (without default values,
varargs
orvoid
types) of routines in theposition
field of their symbols (could be attached to the type instead but there is no space inTType
), and whether or not they have avarargs
parameter into the type flagtfHasVarargsParam
of the routine type.Then use these along with
tfVarargs
(C-style{.varargs.}
) to check, before any parameter match, to see if the given parameter count in a call expression is compatible with the parameter count of the routine.This makes
untyped
parameters evade type checking in some cases (hence the linked issues) but also has a general benefit of ending the match check way earlier.Disabled for nimsuggest because it uses the old behavior to give suggestions for partial calls, however I don't know if there is a way to disable this only when giving suggestions for partial calls.
Also legacy switch for old behavior