Skip to content

fixes #23765; Method calling proc with return value overlapping decla…#25794

Draft
ringabout wants to merge 4 commits into
develfrom
pr_orc
Draft

fixes #23765; Method calling proc with return value overlapping decla…#25794
ringabout wants to merge 4 commits into
develfrom
pr_orc

Conversation

@ringabout
Copy link
Copy Markdown
Member

…red generic type generates invalid C

fixes #2376

This pull request refines type comparison logic in the compiler to be more precise by considering backend alias types, and adds a regression test for a previously reported bug. The main changes are grouped below:

Compiler: Improved Type Comparison

  • Updated sameInstantiation in compiler/seminst.nim to include the PickyBackendAliases flag when comparing concrete types, ensuring backend type aliases are treated strictly during instantiation checks.
  • Updated searchInstTypes in compiler/semtypinst.nim to add the PickyBackendAliases flag when comparing generic parameters, improving correctness for type searches involving backend aliases.

Testing: Regression Coverage

Copilot AI review requested due to automatic review settings May 6, 2026 13:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request tightens the compiler’s type-instantiation equality logic so that backend alias types are compared more strictly, preventing incorrect cache hits that can lead to invalid C code generation in certain generic/method scenarios (regression: #23765).

Changes:

  • Updated sameInstantiation (generic proc instantiation cache) to compare concrete types with PickyBackendAliases.
  • Updated searchInstTypes (generic type instantiation cache lookup) to compare generic parameters with PickyBackendAliases.
  • Added a C/C++ codegen regression test reproducing issue #23765.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/ccgbugs2/tcodegen.nim Adds regression coverage for #23765 (generic instantiation + method call leading to invalid C previously).
compiler/semtypinst.nim Makes cached generic type instantiation lookup stricter by considering backend alias types.
compiler/seminst.nim Makes generic proc instantiation equivalence stricter by considering backend alias types.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/ccgbugs2/tcodegen.nim
@ringabout ringabout marked this pull request as draft May 23, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cpuRelax not defined on ARM

2 participants