Skip to content

Unexpected behavior with range types and custom operators #24032

@fierce-goose

Description

@fierce-goose

Description

proc `++`(n: var int) =
    n += 1

type
    r = range[ 0..15 ]

var a: r = 15

++a

echo a

this code should have thrown an error because I'm trying to assign a variable a value larger than possible, but it just goes beyond the allowed limits without error

Nim Version

Nim Compiler Version 2.0.8 [Linux: amd64]

Current Output

16

Expected Output

sysFatal
Error: unhandled exception: over- or underflow [OverflowDefect]

Known Workarounds

No response

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions