Closed
Description
The compiler crashes with the following example, where FloatGen
is defined as an alias to Gen[float, 8]
.
Example
type
Gen[T; U: int] = object
a: array[U, T]
proc initGen[T; U: int](): Gen[T, U] =
result = Gen[T, U]()
result.a = []
type
FloatGen = Gen[float, 8] # this makes the compiler crash
var gen = initGen[float, 8]()
echo gen
Current Output
fatal.nim(39) sysFatal
Error: unhandled exception: int128.nim(72, 11) `arg.sdata(2) == 0` out of range [AssertionError]
Expected Output
This is the output when the type alias is removed, it's also the expected error message.
/usercode/in.nim(9, 18) template/generic instantiation of `initGen` from here
/usercode/in.nim(7, 14) Error: type mismatch: got <array[0..-1, empty]> but expected 'array[int, float]'
Additional Information
$ nim -v
Nim Compiler Version 1.0.0 [Linux: amd64]
Compiled at 2019-09-23
Copyright (c) 2006-2019 by Andreas Rumpf
git hash: f7a8fc46c0012033917582eb740dc0343c093e35
active boot switches: -d:release
Metadata
Metadata
Assignees
Labels
No labels