Skip to content

Commit

Permalink
Fixes an issue where two types can collide in the cgen
Browse files Browse the repository at this point in the history
When generating a header with `--header` and then using it from another Nim project to import the generated types, generic instances can collide and produce an error i.e. `typedef MyGeneric[TypeA] typename` `typedef MyGeneric[TypeB] typename` `signature` here cant be the same as they are different types.  This issue can be avoided by using the Nim type as part of the name which is what PR does.
  • Loading branch information
jmgomez committed Aug 10, 2024
1 parent d76ea4f commit 657b950
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/ccgtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ proc getTypeDescAux(m: BModule; origTyp: PType, check: var IntSet; kind: TypeDes
# The resulting type will include commas and these won't play well
# with the C macros for defining procs such as N_NIMCALL. We must
# create a typedef for the type and use it in the proc signature:
let typedefName = "TY" & $sig
let typedefName = "TY$1_$2" % [$sig, m.encodeType(origTyp)]
m.s[cfsTypes].addf("typedef $1 $2;$n", [result, typedefName])
m.typeCache[sig] = typedefName
result = typedefName
Expand Down

0 comments on commit 657b950

Please sign in to comment.