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

Suggestion: Relax CS0748 for lambdas receiving a ref/out parameter #2863

Closed
Joe4evr opened this issue Oct 5, 2019 · 2 comments
Closed

Suggestion: Relax CS0748 for lambdas receiving a ref/out parameter #2863

Joe4evr opened this issue Oct 5, 2019 · 2 comments

Comments

@Joe4evr
Copy link
Contributor

Joe4evr commented Oct 5, 2019

This is quite minor, but I'd like to throw it out there for discussion and consideration.

Suppose you have a delegate that receives a parameter by ref/out:

public delegate void RefAction<T, TState>(ref T obj, TState state);

// API method:
public void M<TState>(RefAction<Foo, TState> action, TState state);

Currently, writing a lambda of this signature requires writing out the full parameter list.

M((ref Foo foo, Bar bar) => { ... }, someBar);

It'd be much nicer (and more intuitive) if the ref can be applied while still having the parameters implicitly typed:

// Currently yields 'CS0748: Inconsistent lambda parameter usage; parameter types must be all explicit or all implicit'
M((ref foo, bar) => { ... }, someBar);
@svick
Copy link
Contributor

svick commented Oct 5, 2019

This is a duplicate of #338.

@Joe4evr
Copy link
Contributor Author

Joe4evr commented Oct 5, 2019

Okay, this is why such suggestions should list the error number because that's what I searched on before opening. 🙄

@Joe4evr Joe4evr closed this as completed Oct 5, 2019
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

No branches or pull requests

2 participants