-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Compiler chooses params span overload in expression trees leading to errors #73743
Comments
Oh that's interesting. And something we didn't consider when we had the intuition of "calling the span version is always better" :) This is def worth bringing to LDM to discuss. |
@AlekseyTs this seems a potentially problematic case. Expression trees can't work with the new overloads but it's also quite logical for them to bind to them. Not sure that we have any precedence for this in the language. Definitely have cases where we say an expression tree can't use a feature but this is more we need it to change binding within expression trees. Don't have any good intuition on how to solve this. |
If the behavior won't be changed, consider adding an analyzer that could fix all of these instances. |
From https://github.com/dotnet/csharplang/blob/main/meetings/2024/LDM-2024-06-17.md#conclusion:
|
It looks to me that we already produce a unique enough error message for the scenario. Specifically, I am referring to
It is true that the error is not limited to span scenarios, but I think that the suggested IDE fix will be helpful for users in non-span scenarios as well. |
Moving to IDE to offer the suggested fix. |
@CyrusNajmabadi Could you please route this issue accordingly? Add the right labels, etc. |
Have the same issue with:
Getting these 2 errors: 3 string format variant and works like a charm.. All Arguments ARE of type string... |
You can workaround this by passing an array explicitly like: string.Format("....", new[] { arg1String, arg2String, arg3String, arg4String }) |
Good to know, thank you very much. |
Dupe of #74030 |
Version Used:
4.11.0-2.24268.2+b9c35f1021d2d9d40521474c388d49ee7580ec98
Steps to Reproduce:
Minimal repro: exprSpan.zip
(sharplab doesn't yet have params span feature)
This could be seen as a source-breaking change for folks if they hit in conjunction with seeing new params span overloads for framework APIs. That's what happened here dotnet/efcore@dae7d42
Diagnostic Id:
CS8640, CS9226
Expected Behavior:
No error
Actual Behavior:
The text was updated successfully, but these errors were encountered: