Open etan-status opened 5 months ago
The type of Y[X].T
is typedesc[X]
, but it also stores the info of the symbol T
of the original unresolved generic param and this is what getTypeInst
gives. This symbol is given to the type here and here (with linkTo
).
From what I understand this shouldn't happen, a typedesc
type should not have a bound symbol unless it is literally typedesc
. But I don't know which makes the most sense to do:
linkTo
lines in readTypeParameter
and just return an nkType
node; this might lose information or break stuffand t.sym != nil
condition in mapTypeToAstX
, add and t.kind != tyTypeDesc
; this seems too specificand t.kind notin {tyTypeDesc, tyAlias}
instead. That is, the only types where an "instantiation symbol" is ignored in favor of the implementation become typedescs or primitive alias types like type T = X
. This has the caveat of defining new behavior for getTypeInst
that might be incompatible with old behavior. We could also combine the first option with and t.kind != tyAlias
instead but this seems more independent of compiler internals.Edit: Actually I think hasCustomPragma
should deal with tyAlias
, getTypeInst
shouldn't skip it.
I don't understand the purpose of taking the generic T before hasCustomPragma
echo Y[X].T.hasCustomPragma(p) # why do you need to work on the typedesc ?
echo Y[X].t.hasCustomPragma(p) # Works
Description
Nim Version
% nim -v Nim Compiler Version 1.6.20 [MacOSX: amd64] Compiled at 2024-06-08 Copyright (c) 2006-2023 by Andreas Rumpf
git hash: 19fdbfc173bfccb64cb64e0a963e69f52f71fc73 active boot switches: -d:release
Current Output
Expected Output
Possible Solution
Use
typeof(default(Y[X]).t).hasCustomPragma(p)
instead. But this is not always feasible as the innert
may not be exported in all situations.Additional Information
Possibly related to https://github.com/nim-lang/Nim/issues/23564