Nim
Nim copied to clipboard
implicit compile time conversion int to ranged float causes compiler `fatal` error
Example
type Percent = range[0.0 .. 1.0]
# type Percent = float # using unlimited `float` works fine
proc initColor*(alpha: Percent): bool =
echo alpha
const moduleInstanceStyle = initColor(1)
# let moduleInstanceStyle = initColor(1) # using runtime conversion works fine
Current Output
compiler fatal error:
..................................................................fatal.nim(53) sysFatal
Error: unhandled exception: field 'floatVal' is not accessible for type 'TFullReg' using 'kind = rkInt' [FieldDefect]
Expected Output
compiles successfully
Additional Information
$ nim -v
Nim Compiler Version 1.7.1 [Windows: amd64]
Compiled at 2022-07-17
Copyright (c) 2006-2022 by Andreas Rumpf
active boot switches: -d:release