Skip to content

add a warning/error when a for-in loop range is empty #27720

Description

@rilaaax

Describe the feature

When using an empty range with int literals in a for-in loop, I think we should add en error or at least a warning.

fn main() {
	for i in 4 .. 2 {
		println(i) // unreachable
	}
}

Use Case

Avoid unreachable code

Proposed Solution

Simple update of the for checker

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Version used

0.5.1

Environment details (OS name and version, etc.)

not relevant

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions