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

Utf8String doesn't work with pattern matching #60747

Closed
hez2010 opened this issue Apr 14, 2022 · 2 comments
Closed

Utf8String doesn't work with pattern matching #60747

hez2010 opened this issue Apr 14, 2022 · 2 comments
Labels
Area-Compilers Area-Language Design Resolution-By Design The behavior reported in the issue matches the current design untriaged Issues and PRs which have not yet been triaged by a lead
Milestone

Comments

@hez2010
Copy link

hez2010 commented Apr 14, 2022

Version Used: master

Steps to Reproduce:

I try to use pattern matching with Utf8String but seems that it is not yet supported.

https://sharplab.io/#v2:EYLgtghglgdgPgAQEwEYCwAoTsAuACAMQHsiUAKAJQFMIATAeRgBsBPAZQAcIYAeYFnFQB8eAM4BKTAG9MeOXgQB2MWIDuUHAGMAFrPkyM8o3gBEAMxImArgA48AXhEoANHuOngEAE7W7jvEiuhu54APoOIgAMbngAvgDcmLGY2DD4xERIZJzcfALCYpIYBkZKKqLqWrrBciUh5pa2EXguMUYmnj5N/oFt8uH+0TVxiRjJWBi4hCQAzGT8ggDaALqF0jFlomoaOjF17g1Evs2tw+2dxz1BIWHNQ0YJSUA===

Expected Behavior:

Code can be compiled.

Actual Behavior:

error CS0150: A constant value is expected

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 14, 2022
@Youssef1313
Copy link
Member

This behavior is by design. A utf8 string isn't a constant (it's lowered to byte array creation). So it cannot be used in pattern matching. You also cannot assign it to a constant.

@jcouv
Copy link
Member

jcouv commented Apr 15, 2022

Tagging @AlekseyTs as FYI.
Closing as by design. We're tracking this language question in #58848 (under language design meeting "LDM" section).

@jcouv jcouv closed this as completed Apr 15, 2022
@jcouv jcouv added Resolution-By Design The behavior reported in the issue matches the current design Area-Language Design labels Apr 15, 2022
@jcouv jcouv added this to the 17.3 milestone Apr 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Area-Language Design Resolution-By Design The behavior reported in the issue matches the current design untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

3 participants