Skip to content

Possible typo in type inference #787

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

Closed
jskeet opened this issue May 9, 2023 · 2 comments
Closed

Possible typo in type inference #787

jskeet opened this issue May 9, 2023 · 2 comments
Assignees
Labels
meeting: discuss This issue should be discussed at the next TC49-TG2 meeting type: bug The Standard does not describe the language as intended or implemented
Milestone

Comments

@jskeet
Copy link
Contributor

jskeet commented May 9, 2023

From https://github.com/dotnet/csharpstandard/blob/draft-v7/standard/expressions.md#12632-the-first-phase, after an introduction which sets the scene with:

Tₑ M<X₁...Xᵥ>(Tp₁ ... Tₓ pₓ)

we have this text:

For each of the method arguments Eᵢ:

  • If Eᵢ is an anonymous function, an explicit parameter type inference (§12.6.3.8) is made from Eᵢ to Tᵢ
  • Otherwise, if Eᵢ has a type U and xᵢ is a value parameter (§15.6.2.2) then a lower-bound inference (§12.6.3.10) is made from U to Tᵢ.
  • Otherwise, if Eᵢ has a type U and xᵢ is a reference (§15.6.2.3) or output (§15.6.2.4) parameter then an exact inference (§12.6.3.9) is made from U to Tᵢ.
  • Otherwise, no inference is made for this argument.

Should the xᵢ in the second and third bullets be pᵢ?

I'll probably just create a PR for this, but it was easier to file an issue to start with...

@jskeet jskeet added the type: bug The Standard does not describe the language as intended or implemented label May 9, 2023
@jskeet jskeet self-assigned this May 9, 2023
@jskeet jskeet added the meeting: discuss This issue should be discussed at the next TC49-TG2 meeting label May 23, 2023
@jskeet jskeet added this to the Pre-C# 8.0 milestone Sep 21, 2023
@Nigel-Ecma
Copy link
Contributor

Nigel-Ecma commented Oct 30, 2023

Well a parameter has the grammar:

attributes? parameter_modifier? type identifier default_argument?

Matching Tₑ M<X₁...Xᵥ>(T₁ p₁ ... Tₓ pₓ) to this the Tᵢ are the type and pᵢ the identifier. Neither of these determine whether the parameter is value or reference parameter, that is down to the parameter_modifier. So it seems the writer is using xᵢ as the whole parameter spec but does not define it as such, so the xᵢ are neither pᵢ or Tᵢ

We could try:

  • Otherwise, if Eᵢ has a type U and the ith parameter is a value parameter (§15.6.2.2) then a lower-bound inference (§12.6.3.10) is made from U to Tᵢ.
  • Otherwise, if Eᵢ has a type U and the ith parameter is a reference (§15.6.2.3) or output (§15.6.2.4) parameter then an exact inference (§12.6.3.9) is made from U to Tᵢ.

Which skirts introducing another letter and requires HTML <sup> tags in the source :-)

jskeet pushed a commit that referenced this issue Nov 1, 2023
Fix for issue #787

The PR uses “corresponding parameter” rather than the “ith parameter" from #787. I think this is better, avoids HTML tags, and matches the use of corresponding parameter elsewhere; but either choice is valid.
@jskeet
Copy link
Contributor Author

jskeet commented Nov 1, 2023

Fixed in #975

@jskeet jskeet closed this as completed Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meeting: discuss This issue should be discussed at the next TC49-TG2 meeting type: bug The Standard does not describe the language as intended or implemented
Projects
None yet
Development

No branches or pull requests

2 participants