Skip to content
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

mirtypes: fix regression with cyclic generic object types #1398

Conversation

zerbina
Copy link
Collaborator

@zerbina zerbina commented Aug 5, 2024

Summary

Fix cyclic generic object types instantiated with tuple types as one
of the arguments causing C compiler errors under some circumstances.

Details

  • the type merging logic in mirtypes now uses sighashes, which is
    able to handle cyclic types
  • previously, Obj[(int,)] and Obj[tuple[x: int]] were not being
    merged into one when Obj is cyclic
  • this led to C compiler errors when assigning between such types, or
    when the type has hooks (explicit or synthesized) that are called

Summary
=======

Fix cyclic generic object types instantiated with tuple names as
arguments causing C compiler errors in some circumstances.

Details
=======

* the type merging logic in `mirtypes` now uses `sighashes`, which is
  able to handle cyclic types
* previously, `Obj[(int,)]` and `Obj[tuple[x: int]]` were not being
  merged into one when `Obj` is cyclic
* this led to C compiler errors when assigning between such types, or
  when the type has hooks (explicit or synthesized) that are called
`vmtypegen` doesn't yet use the MIR type IR, meaning that it's
oblivious to the canoniclization.
@zerbina zerbina added bug Something isn't working compiler/backend Related to backend system of the compiler labels Aug 5, 2024
@zerbina zerbina added this to the MIR phase milestone Aug 5, 2024
@saem
Copy link
Collaborator

saem commented Aug 5, 2024

/merge

Copy link

github-actions bot commented Aug 5, 2024

Merge requested by: @saem

Contents after the first section break of the PR description has been removed and preserved below:


Notes for Reviewers

  • a regression introduced by mir: add a dedicated IR for types #1382
  • this fixes the last -Wincompatible-pointer-types warning when booting the compiler,
    meaning that the compiler can be build with GCC 14 again

@chore-runner chore-runner bot added this pull request to the merge queue Aug 5, 2024
Merged via the queue into nim-works:devel with commit f110824 Aug 5, 2024
31 checks passed
@zerbina zerbina deleted the fix-cyclic-generic-object-type-regression branch August 5, 2024 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler/backend Related to backend system of the compiler
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants