nim-works / nimskull

An in development statically typed systems programming language; with sustainability at its core. We, the community of users, maintain it.
https://nim-works.github.io/nimskull/index.html
Other
275 stars 39 forks source link

fix: compiler crash when compiling for iOS #1441

Closed zerbina closed 1 month ago

zerbina commented 1 month ago

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 the system module, all calls to sizeof outside of generic routines resolve to the sizeof(x: T) symbol, foregoing overload resolution since sizeof 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 of syslocks), the first parameter's type of the callee reaching mirgen is a tyGenericParam, and thus mirgen.genArgs attempts to translate the skType symbol like a normal expression, triggering an assertion.

Always using overload resolution for sizeof would result in unnecessary generic instantiations, so mirgen now uses dedicated handling for the mSizeOf magic, always translating argument as a type, thus fixing the crash.

Fixes https://github.com/nim-works/nimskull/issues/1436.

saem commented 1 month ago

/merge

github-actions[bot] commented 1 month ago

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