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

Restrict implicit args to using #22458

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

som-snytt
Copy link
Contributor

Typer#adaptNoArgsImplicitMethod populates implicit args when an arg list is missing. To remedy missing implicits, it tries a named application using args it did find. Then Applications#tryDefault supplies a default arg if available. A previous fix to allow tryDefault to supply implicit args for implicit params is now restricted to explicit using; typer now adds using for implicit when it needs to try defaults.

This commit restores propagatedFailure and the previous condition that default params are tried if there is an error that is not an ambiguity. An additional restriction is that default params must be useful: there must be a param which has a default arg to be added (because it's not a named arg).

Fixes #22439

@som-snytt
Copy link
Contributor Author

Aspirationally,

Since issueErrors specifies endPos, the position used for
implicitArgTree by matchArgs is also tweaked to be the endPos
(of the appPos). That places a single caret in the familiar
spot following the existing application, instead of underlining.

That needs a mechanism for distinguishing user's using from typing for default args, where user expr requires underlining, but the latter case wants trailing caret.

@som-snytt som-snytt marked this pull request as ready for review January 26, 2025 10:32
@EugeneFlesselle
Copy link
Contributor

I'm in my exam period until 05/02, so I won't be able to review before then. I'll be happy to take a look once I can though.

@som-snytt som-snytt requested review from mbovel and removed request for EugeneFlesselle January 27, 2025 22:07
@som-snytt
Copy link
Contributor Author

@mbovel you were in this area last spring, and the LOC I restored will be familiar to you. (Maybe over-familiar.) If you wouldn't mind revisiting it for a review? This commit tweaks Eugene's previous fix by tweaking your previous fix.

@som-snytt som-snytt force-pushed the issue/22439-empty-implicit-app branch from 56a9d3b to 32c0f84 Compare February 2, 2025 01:00
Typer#adaptNoArgsImplicitMethod populates implicit args
when an arg list is missing. To remedy missing implicits,
it tries a named application `using` args it did find.
Then Applications#tryDefault supplies a default arg if
available. A previous fix to allow tryDefault to supply
implicit args for `implicit` params is now restricted
to explicit `using`; typer now adds `using` for `implicit`
when it needs to try defaults.

This commit restores propagatedFailure and the previous
condition that default params are tried if there is an error
that is not an ambiguity. An additional restriction is that
default params must be useful: there must be a param which
has a default arg to be added (because it's not a named arg).
@som-snytt som-snytt force-pushed the issue/22439-empty-implicit-app branch from 32c0f84 to f43543f Compare February 17, 2025 23:23
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

Successfully merging this pull request may close these issues.

Implicits are resolved with empty parameter lists
3 participants