Open
Description
Description
I have taken this example for static parameters from the manual but it is not working as expected.
It seems the type class (Number) constraints on the value type of the matrices in the example are not working:
type
Number = int32 or float32
Matrix[M,N: static int; T: Number] = array[0..(M*N - 1), T]
# Note how `Number` is just a type constraint here, while
# `static int` requires us to supply an int value
AffineTransform2D[T] = Matrix[3, 3, T]
AffineTransform3D[T] = Matrix[4, 4, T]
var m1: AffineTransform3D[float] # OK
var m2: AffineTransform2D[string] # This should generate error - `string` is not a `Number` and compilation should fail
Nim Version
Nim Compiler Version 1.9.1 [Linux: amd64]
Compiled at 2023-02-20
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: e896977
active boot switches: -d:release
Current Output
Hint: used config file '/home/raych/prg/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/raych/prg/Nim/config/config.nims' [Conf]
......................................................................
/home/raych/prg/nim_examples_from_manual/static_types_ex.nim(10, 5) Hint: 'm2' is declared but not used [XDeclaredButNotUsed]
/home/raych/prg/nim_examples_from_manual/static_types_ex.nim(9, 5) Hint: 'm1' is declared but not used [XDeclaredButNotUsed]
CC: static_types_ex.nim
Hint: [Link]
Hint: mm: orc; threads: on; opt: none (DEBUG BUILD, `-d:release` generates faster code)
27551 lines; 0.124s; 30.32MiB peakmem; proj: /home/raych/prg/nim_examples_from_manual/static_types_ex.nim; out: /home/raych/prg/nim_examples_from_manual/static_types_ex [SuccessX]
Hint: /home/raych/prg/nim_examples_from_manual/static_types_ex [Exec]
Expected Output
Compiler error should be produced and the compilation should fail.
Possible Solution
No response
Additional Information
No response