PolySharp icon indicating copy to clipboard operation
PolySharp copied to clipboard

Support Range for non ValueTuple by remove the GetOffsetAndLength method

Open wherewhere opened this issue 2 years ago • 5 comments

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 avatar Dec 11 '23 11:12 wherewhere

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

wherewhere avatar Dec 11 '23 12:12 wherewhere

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.

hez2010 avatar Dec 20 '23 03:12 hez2010

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.

wherewhere avatar Dec 20 '23 08:12 wherewhere

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.

hez2010 avatar Dec 20 '23 09:12 hez2010

...

wherewhere avatar Dec 20 '23 11:12 wherewhere