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

fix double-free and compiler crash #1414

Merged
merged 3 commits into from
Aug 14, 2024

Conversation

zerbina
Copy link
Collaborator

@zerbina zerbina commented Aug 13, 2024

Summary

  • fix a double-free issue when assigning to sink parameters of
    instantiated generic tuple type
  • fix a compiler crash when passing an empty seq, array, or set
    construction to a generic instantiation receiver type

Fixes #1415.

Details

Post-match fitting didn't consider generic tuple instantiations when
applying implicit conversions, meaning that the nkHiddenSubConv or
nkHiddenStdConv inserted earlier by sigmatch stayed.

This led to two issues:

  • nkStmtListExprs of empty container type didn't have their types
    fixed properly, causing crashes when the empty type reached into the
    MIR phase
  • a conversion between sink T and T is considered an rvalue
    conversion by proto_mir, which resulted in assignments involving
    these implicit conversions effectively being shallow assignments
    (and thus double frees)

Skipping tyGenericInst and tyAlias (for good measure) makes sure
the implicit conversion is collapsed when the destination type is a
generic instantiation, fixing both issues. A test is added for both.

@zerbina zerbina added bug Something isn't working compiler/sem Related to semantic-analysis system of the compiler labels Aug 13, 2024
@saem
Copy link
Collaborator

saem commented Aug 14, 2024

/merge

Copy link

Merge requested by: @saem

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


Notes for Reviewers

@chore-runner chore-runner bot added this pull request to the merge queue Aug 14, 2024
Merged via the queue into nim-works:devel with commit a1decd8 Aug 14, 2024
35 checks passed
@zerbina zerbina deleted the sem-fix-post-match-fitting-bug branch August 25, 2024 23:56
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/sem Related to semantic-analysis system of the compiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

double destroy with sink and generic tuple type
2 participants