Skip to content

Partial and _ generic arguments at calls - #1990

Merged
sbillig merged 5 commits into
argotorg:masterfrom
sbillig:feat/partial-generic-args
Nov 12, 2026
Merged

sbillig merged 5 commits into
argotorg:masterfrom
sbillig:feat/partial-generic-args

Conversation

@sbillig

@sbillig sbillig commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

A call may now give only some of its callee's generic arguments. They fill the parameters from the left, and each one left out takes its default or is inferred, as when none are given: op<1>(c) calls fn op<const N: u64, F: Rules>(_ c: Cursor<F>) with F inferred from c. Generic handlers like fevm's can then write self.op_push<1>(c, mut tracer) rather than spelling out types the arguments already give.

_ asks for one argument to be inferred, even where the parameter has a default, so a later argument can be given while an earlier one is inferred: len<_, 3>(xs). It is allowed only as a whole generic argument of a call (function, method and associated function calls, and function item values); anywhere else it is 3-0094. The parser, formatter and tree-sitter grammar accept it, and the vendored tree-sitter wasm is regenerated.

8-0022 now reports only too many generic arguments. When a call leaves a parameter uninferred, 8-0031 names the parameter and shows the call that would give it, instead of suggesting an unwritable : fn op<_> annotation.

When a call left a function's generic parameter uninferred, 8-0031
suggested an annotation of the function item's type, such as
"consider giving `: fn width<_>` here", which can't be written. Name
the parameter instead, and show the generic arguments that would give
it: "cannot infer the const parameter `N` of `width`" and
"consider giving it explicitly: `width<N>`".
A call had to give all of its callee's generic arguments or none:
`op<1>(c)` for `fn op<const N: u64, F: Rules>(_ c: Cursor<F>)` was
8-0022. Now the given arguments fill the parameters from the left, and
each omitted parameter takes its default or is inferred, as when no
arguments are given. 8-0022 now reports only too many arguments.
`op<1, _>(c)` didn't parse: the generic argument list failed, so `<`
was read as a comparison. `_` is now a generic argument of its own kind
in the parser, AST, HIR, formatter and tree-sitter grammar, and the
vendored tree-sitter wasm is regenerated. Anywhere it is written,
`_` is reported as 3-0094 for now.
A `_` among a call's generic arguments now stays the inference variable
its callee was instantiated with, even where the parameter has a
default, so `op<1, _>(c)` infers `F` and `len<_, 3>(xs)` gives a later
argument while inferring an earlier one. This covers function, method
and associated function calls and function item values. Anywhere else,
including inside a call's argument as in `f<Vec<_>>(x)`, `_` is still
3-0094.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T17:57:40.887660Z c7c490c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sbillig
sbillig merged commit 07895f9 into argotorg:master Nov 12, 2026
10 checks passed
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.

1 participant