-
Notifications
You must be signed in to change notification settings - Fork 39
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
fix C compilation errors with closures and nested types #1397
fix C compilation errors with closures and nested types #1397
Conversation
Summary ======= Fix a bug with hook synthesis that led to C compiler errors when using some closure procedures or `ref`s with non-top-level `object` types. Details ======= * `sighashes` now uses the symbol ID as the object representation for anonymous object/enum types and object/enum types not defined at the top-level * this means that `hashType(x) != hashType(y)` when `sameType(x, y) == false`, for object and enum types * as a consequence, unique hook procedures are used for `ref T` types that used the aforementioned types for `T` * RTTI, which is assigned to types based on type hashes, also uses unique instances per object type now Multiple same-shaped anonymous/non-top-level object types are *not* merged into a single one by the C code generator, which due to all sharing the same set of hook procedures, resulted in C compiler errors due to implicit conversions between incompatible pointer types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
if t.sym.flags * {sfAnon, sfGenSym} != {} or | ||
(t.kind == tyObject and t.owner.kind == skType and | ||
tfRefsAnonObj in t.owner.typ.flags): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the top level check wouldn't it make sense to check if the owning symbol is not an skModule
, or would that be a problem for generic instantiations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing whether the owner is an skModule
symbol wouldn't be able to detect the Nested
type from tseparate_hooks1.nim
(where the owner is a module symbol).
sem
marks such types' symbols with the sfGenSym
at the moment, so that they can be detected here. The only proper solution to this mess is getting rid of sighashes
, really.
Co-authored-by: Saem Ghani <[email protected]>
/merge |
Merge requested by: @saem Contents after the first section break of the PR description has been removed and preserved below:
|
Summary
Fix a bug with hook synthesis that led to C compiler errors when using
some closure procedures or
ref
s of non-top-levelobject
type.Details
sighashes
now uses the symbol ID as the object representation foranonymous object/enum types and object/enum types not defined at the
top-level
hashType(x) != hashType(y)
whensameType(x, y) == false
, for object and enum typesref T
typesthat used the aforementioned types for
T
unique instances per object type now
Multiple same-shaped anonymous/non-top-level object types are not
merged into a single one by the C code generator, which due to all
sharing the same set of hook procedures, resulted in C compiler errors
due to implicit conversions between incompatible pointer types.