Closed zerbina closed 1 month ago
/merge
Merge requested by: @saem
Contents after the first section break of the PR description has been removed and preserved below:
## Notes for Reviewers * the issues only occurred for `sizeof` call within the `system` module, so no standalone regression test is possible
Summary
Fix a compiler crash when compiling any program for iOS with threading enabled. Only the iOS target was affected.
Details
Due to
StrTab
ordering, within thesystem
module, all calls tosizeof
outside of generic routines resolve to thesizeof(x: T)
symbol, foregoing overload resolution sincesizeof
is an "eager" magic.If called with the symbol of a type that has an unknown size (which happens in a
when defined(ios)
guarded part ofsyslocks
), the first parameter's type of the callee reachingmirgen
is atyGenericParam
, and thusmirgen.genArgs
attempts to translate theskType
symbol like a normal expression, triggering an assertion.Always using overload resolution for
sizeof
would result in unnecessary generic instantiations, somirgen
now uses dedicated handling for themSizeOf
magic, always translating argument as a type, thus fixing the crash.Fixes https://github.com/nim-works/nimskull/issues/1436.