Skip to content

Syntax: clarification on "unused" keyword placement #6448

@burakemir

Description

@burakemir

Summary of issue:

The accepted proposal PR #2022 Unused Pattern Bindings introduces a new keyword "unused" which should be placed right in front of a name.

Since then, there have been some changes to binding patterns.

Can you confirm that the choice that unused should be right in front of the name (not patterns) still holds?

Details:

The proposal text says only names and not patterns should be in scope of the unused marker.

Is this still our choice?

Consequently:

  • one would write ref unused name x: i32 to get a name marked as unused.
  • writing unused ref name x: i32 would be a parse error.

An additional minor question:

  • When someone uses both markers in a binding, e.g. unused _ : i32, should there be a warning that says that the unused keyword has no effect on _?

EDIT: adding three more clarification questions:

  • Question 3 - If I have fn F(o: C) { var _ : o.Inner }, we should still consider o unused, correct?

  • Question 4 - There is a check to ensure implementations are the same as interface methods. I believe this check should skip over unused markers. Can you confirm?

  • Question 5 - Can you confirm that "unused" markers do not seem to make sense on interface methods, as they should not be part of contract. Should we flag this as error?
    To put it more neutrally: if we do not update the check, then "unused" on an interface of virtual method declaration will force implementations to have unused markers, and thus force the parameters to not be used. This seems undesirable?

Any other information that you want to share?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    blocking workIndicates someone's work is currently blocked on the issue being resolved.leads questionA question for the leads team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions