Skip to content

Compiler creates invalid out-of-range int8 constants. #13513

Closed
@markus-oberhumer

Description

@markus-oberhumer

The compiler creates an invalid int8 constant with the value 128.

Example

const a = high(int8)
const b = a +% 1

doAssert typeof(b) is int8

doAssert b == 128                # INVALID BUT WORKS !!!
doAssert b <= high(int8)         # FAILS

Current Output

Error: unhandled exception: /tmp/test.nim(7, 10) `b <= high(int8)`  [AssertionError]

Expected Output

b should be -128
$ nim -v
Nim Compiler Version 1.1.1 [Linux: amd64]
Compiled at 2020-02-26
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: f091b5a0ee9b5585a08e9130d3ec682a9526ef39
active boot switches: -d:release

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