Skip to content

converter fails to work with multiple generic types #4554

@jxy

Description

@jxy

With the following code

type
  G[N:static[int]] = object
    v: int
  F[N:static[int]] = object
    v: int
static:
  echo(G[1] is G[2])
  echo(G[1] is F[1])
converter G2int[N:static[int]](x:G[N]):int = x.v
converter F2int[N:static[int]](x:F[N]):int = x.v
proc p(x,y:int) = echo "p ",x," ",y
var
  g1 = G[1](v:1)
  g2 = G[2](v:20)
  f1 = F[1](v:1000)
  f2 = F[2](v:200)
p(g1,g2)    # Error: type mismatch: got (G[1], G[2])
p(f1,f2)    # Error: type mismatch: got (F[1], F[2])
p(g1,g1)    # compiles
p(f1,f1)    # compiles
p(g1,f1)    # compiles
p(f1,g1)    # compiles
p(g1,f2)    # compiles
p(f1,g2)    # compiles

the first two calls, p(g1,g2) and p(f1,f2), fail with type mismatch complained by the compiler. However, the other calls compile and run fine.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions