Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getTypeInst returns different results for type aliased generics depending on code order #19042

Open
quantimnot opened this issue Oct 23, 2021 · 1 comment

Comments

@quantimnot
Copy link
Contributor

Example

import macros, sequtils, options

when not defined skipBad:
  proc breaksStuff(a: Option[seq[string]]) = discard

when not defined skipBad:
  var alsoBreaksStuff: Option[seq[string]]

type
  StrSeq = seq[string]
  A = object
    b: Option[StrSeq]

proc doesNotAffectAnything(a: Option[seq[string]]) = discard
var alsoDoesNotAffectAnything: Option[seq[string]]

macro c(t: typedesc) =
  echo $t.getType[1].getType[2].children.toSeq[0].getTypeInst[1].kind

c A

Current Output

nnkBracketExpr

Expected Output

nnkSym

Additional Information

Problem exists in 0.14.0 and recent devel: f0af4a3.

@quantimnot quantimnot changed the title getTypeInst returns defferent results depending on code order getTypeInst returns different results for type aliased generics depending on code order Oct 24, 2021
@theAkito
Copy link
Contributor

theAkito commented Nov 5, 2023

Happens without type alias, as well.

import macros, sequtils, options

when not defined skipBad:
  proc breaksStuff(a: Option[seq[string]]) = discard

when not defined skipBad:
  var alsoBreaksStuff: Option[seq[string]]

type
  A = object
    b: Option[seq[string]]

macro c(t: typedesc) =
  echo $t.getType[1].getType[2].children.toSeq[0].getTypeInst[1]

echo "START"
c A
echo "END"

Result

Error: Invalid node kind nnkBracketExpr for macros.`$`

Nim Version

Nim Compiler Version 2.0.0 [Linux: amd64]
Compiled at 2023-08-01
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: a488067a4130f029000be4550a0fb1b39e0e9e7c
active boot switches: -d:release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants