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

Interpolated string in expression tree lambda doesn't compile #55114

Closed
AndriySvyryd opened this issue Jul 26, 2021 · 2 comments · Fixed by #55125
Closed

Interpolated string in expression tree lambda doesn't compile #55114

AndriySvyryd opened this issue Jul 26, 2021 · 2 comments · Fixed by #55125
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@AndriySvyryd
Copy link
Member

The following works in .NET 5:

Func<IQueryable<string>, IQueryable<string>> f = s => s.Select(o => $"{o.Length}")

But in 6.0.100-preview.7.21373.8 it errors out:

error CS8640: Expression tree cannot contain value of ref struct or restricted type 'DefaultInterpolatedStringHandler'.

@ghost
Copy link

ghost commented Jul 26, 2021

Tagging subscribers to this area: @cston
See info in area-owners.md if you want to be subscribed.

Issue Details

The following works in .NET 5:

Func<IQueryable<string>, IQueryable<string>> f = s => s.Select(o => $"{o.Length}")

But in 6.0.100-preview.7.21373.8 it errors out:

error CS8640: Expression tree cannot contain value of ref struct or restricted type 'DefaultInterpolatedStringHandler'.

Author: AndriySvyryd
Assignees: -
Labels:

area-System.Linq.Expressions, untriaged

Milestone: -

@MichalStrehovsky MichalStrehovsky transferred this issue from dotnet/runtime Jul 26, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jul 26, 2021
@stephentoub
Copy link
Member

cc: @333fred

333fred added a commit to 333fred/roslyn that referenced this issue Jul 26, 2021
Introduces a binder flag to track whether we are currently in an expression tree or not. Fixes dotnet#55114.
333fred added a commit to 333fred/roslyn that referenced this issue Jul 26, 2021
Introduces a binder flag to track whether we are currently in an expression tree or not. Fixes dotnet#55114.
333fred added a commit that referenced this issue Jul 27, 2021
* Don't use DefaultInterpolatedStringHandler in expression trees

Introduces a binder flag to track whether we are currently in an expression tree or not. Fixes #55114.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants