nim-works / nimskull

An in development statically typed systems programming language; with sustainability at its core. We, the community of users, maintain it.

Home Page:https://nim-works.github.io/nimskull/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getType doesn't reveal complete generic arguments

disruptek opened this issue · comments

Specification

getType doesn't reveal complete generic arguments even for concrete types.

Example

import std/macros

type
  A[B, C] = object
    x: B
    y: C

  P[B, C] = proc(bar: A[B, C])

proc foo(bar: A[int, float]) =
  discard

macro bug[B, C](a: P[B, C]) =
  echo treeRepr(getType(a))

bug(P[int, float] foo)
bug(foo)

Actual Output

BracketExpr
  Sym "proc"
  Sym "void"
  Sym "A"
BracketExpr
  Sym "proc"
  Sym "void"
  Sym "A"

Expected Output

BracketExpr
  Sym "proc"
  Sym "void"
  BracketExpr
    Sym "A"
    Sym "int"
    Sym "float"
BracketExpr
  Sym "proc"
  Sym "void"
  BracketExpr
    Sym "A"
    Sym "int"
    Sym "float"

Possible Solution

A workaround is to use getTypeInst but I don't see why getType shouldn't work.

Additional Information

Nimskull Compiler Version 0.1.0-dev.21251 [linux: amd64]

Source hash: 5aca007cd7ef41a1128fbe6d6eb667ce612f847c
Source date: 2024-03-06

active boot switches: -d:release -d:danger⏎

Fixed by #1346.