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

List-patterns: lowering assumes the conversion from int to Index will use the implicit conversion operator #57825

Closed
jcouv opened this issue Nov 17, 2021 · 3 comments · Fixed by #58055

Comments

@jcouv
Copy link
Member

jcouv commented Nov 17, 2021

In BindLengthAndIndexerForListPattern we do:
_ = GetWellKnownTypeMember(WellKnownMember.System_Index__op_Implicit_FromInt32, diagnostics, syntax: node);

From Aleksey: Just to clarify. What bothers me here is the fact that lowering never uses this member explicitly, it relies on conversion classification instead, etc. So, we are making an assumption that all that complicated machinery ends up using the method. However, there is no actual guarantee that that would be the case. For example, if method is not marked with special name flag, it won't be considered as a valid conversion operator.

As part of this, we should confirm whether we want list-pattern to lower as expr[0] (using conversion from int to Index) or expr[new Index(0)] (using constructor).

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Nov 17, 2021
@jcouv
Copy link
Member Author

jcouv commented Nov 19, 2021

From discussion with Aleksey, we're leaning towards aligning on constructor. This involves less machinery (no conversion classification) and aligns with what we do for from-end Index values. We'll update the spec to clarify accordingly.
@333fred Sounds okay?

@jcouv jcouv removed the untriaged Issues and PRs which have not yet been triaged by a lead label Nov 19, 2021
@jcouv jcouv modified the milestones: 17.0.1, 17.1 Nov 19, 2021
@333fred
Copy link
Member

333fred commented Nov 19, 2021

From discussion with Aleksey, we're leaning towards aligning on constructor. This involves less machinery (no conversion classification) and aligns with what we do for from-end Index values. We'll update the spec to clarify accordingly. @333fred Sounds okay?

That sounds good to me.

@jcouv
Copy link
Member Author

jcouv commented Nov 21, 2021

Mads also agreed on aligning on constructor (rather than implicit conversion).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants