We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Building on the solution for #13048 (comment)
import macros macro foo*(T: typedesc): typedesc = echo T.getTypeInst.treerepr echo "--------------------------------------" let instantiated = T.getTypeInst echo instantiated.treeRepr[1] # This is the char 'r' return getType(int) type Task = ptr object prev, next: Task parent: Task fn: proc (param: pointer) {.nimcall.} # User data data: array[10, byte] discard foo(typeof(default(Task)[]))
The instantiated.treeRepr returns the character 'r' which is very strange.
Output
BracketExpr Sym "typeDesc" Sym "Task:ObjectType" -------------------------------------- r
The text was updated successfully, but these errors were encountered:
You just called treerepr too early. You're indexing a string, not a NimNode.
Sorry, something went wrong.
That's not it.
If you look closely
echo T.getTypeInst.treerepr echo "--------------------------------------"
returns
BracketExpr Sym "typeDesc" Sym "Task:ObjectType" --------------------------------------
So instantiated[1] => T.getTypeInst[1] should return Sym "Task:ObjectType"
Sym "Task:ObjectType"
If you add an extra line that display the type you can confirm that it returns a char instead of a nnkSym.
char
import macros macro foo*(T: typedesc): typedesc = echo T.getTypeInst.treerepr echo "--------------------------------------" let instantiated = T.getTypeInst echo typeof instantiated.treeRepr[1] echo instantiated.treeRepr[1] # This is the char 'r' return getType(int) type Task = ptr object prev, next: Task parent: Task fn: proc (param: pointer) {.nimcall.} # User data data: array[10, byte] discard foo(typeof(default(Task)[]))
BracketExpr Sym "typeDesc" Sym "Task:ObjectType" -------------------------------------- char r
But that is not what you wrote: instantiated.treeRepr[1]. "BracketExpr..."[1] == 'r'
instantiated.treeRepr[1]
"BracketExpr..."[1] == 'r'
guess I was lacking sleep, good catch.
No branches or pull requests
Building on the solution for #13048 (comment)
The instantiated.treeRepr returns the character 'r' which is very strange.
Output
The text was updated successfully, but these errors were encountered: