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

Support Range for non ValueTuple by remove the GetOffsetAndLength method #93

Open
wherewhere opened this issue Dec 11, 2023 · 5 comments

Comments

@wherewhere
Copy link

Description (optional)

Support Range for non ValueTuple by remove the GetOffsetAndLength method

Rationale

Code like "Hello World"[..5] does not need to use Range. It just be compiled to "Hello World".Substring(0, 5). So please remove GetOffsetAndLength when ValueTuple is not referenced like this Range.cs.

@wherewhere
Copy link
Author

Things like (a, b) = (b, a) does not need to use ValueTuple. Why they have to check ValueTuple existing?

@hez2010
Copy link

hez2010 commented Dec 20, 2023

Things like (a, b) = (b, a) does not need to use ValueTuple. Why they have to check ValueTuple existing?

The final codegen of swapping variables not using ValueTuple due to optimization doesn't mean the compiler won't check the existence of ValueTuple to make sure the ValueTuple feature itself works. And the compiler still needs to get the type ValueTuple so that it can bind the symbols, otherwise the type of (a, b) and (b, a) will be unknown at compile time.

@wherewhere
Copy link
Author

But (a, b) = (b, a) can't be ValueTuple. Create ValueTuple need (var c, var d) = (b, a). Distrust (a, b) = c seems not check ValueTuple.

@hez2010
Copy link

hez2010 commented Dec 20, 2023

You are trying to construct a ValueTuple at the right expression (b, a), but as for (a, b) = c where (a, b) is on the left, it is a completedly unrelated feature called destruction.

@wherewhere
Copy link
Author

...

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