Skip to content

Disallow negative integers as indices #74

@71104

Description

@71104

Currently, int is allowed as index for indexed types (arrays and strings). The reason we can't restrict this to uint is that we want to be able to use expressions like - n 1 as indices. The current implementation of the - operator types to int even if both operands are uint because the result of a subtraction may be negative.

A possible solution is to implement proper 32- or 64-bit unsigned integers and wrap around when a negative value is produced, but this would raise the problem of deciding the width. A possible solution to this would in turn be to provide both 32-bit and 64-bit integer types.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions