Skip to content

VM breaking at template parameter evaluation. #20937

@quantumedbox

Description

@quantumedbox

Description

VM breaks at trying to execute volume procedure:

type
  Vec3*[T: SomeNumber] {.bycopy.} = tuple[x, y, z: T]

func volume*[T](v: Vec3[T]): T =
  when T is SomeUnsignedInt:
    v.x * v.y * v.z
  else:
    abs (v.x * v.y * v.z)

type
  Matrix3*[C: static Vec3[uint], T] = object
    cells: array[C.area, T]

let m = Matrix3[(1.uint, 1.uint, 1.uint), uint](cells: [0.uint])

Nim Version

1.6.8

Current Output

/usercode/in.nim(7, 15) Error: cannot generate VM code for *

Expected Output

Successful compilation.

Possible Solution

No response

Additional Information

Changing 'volume' func to template fixes the problem, so, breaking probably happens on procedure boundaries.

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