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 missing destruction when discarding complex expression #1422

Merged
merged 1 commit into from
Aug 18, 2024

Conversation

zerbina
Copy link
Collaborator

@zerbina zerbina commented Aug 18, 2024

Summary

Fix the result of if, case, block, and try expression not being
destroyed when discarding the expression.

Fixes #1421.

Details

  • in mirgen, a value-like PMIR expression is now requested for the
    discarded expression
  • toValue expects a properly value-like PMIR expression, which a
    complex expression is not, hence the missing destructor
  • the expression is now properly materialized, which means that the a
    destructor call is registered for the temporary

Summary
=======

Fix the result of `if`, `case`, `block`, and `try` expression not being
destroyed when `discard`ing the expression.

Details
=======

* in `mirgen`, a value-like PMIR expression is now requested for the
  discarded expression
* `toValue` expects a properly value-like PMIR expression, which a
  complex expression, hence the missing destructor
* the expression is now properly materialized, which means that the a
  destructor call is registered for the temporary
@zerbina zerbina added bug Something isn't working compiler/backend Related to backend system of the compiler labels Aug 18, 2024
@zerbina zerbina added this to the MIR phase milestone Aug 18, 2024
@saem
Copy link
Collaborator

saem commented Aug 18, 2024

  • toValue expects a properly value-like PMIR expression, which a
    complex expression, hence the missing destructor

I think the bullet point is incomplete, did you mean:

"which a complex expression didn't produce,"?

@zerbina
Copy link
Collaborator Author

zerbina commented Aug 18, 2024

I think the bullet point is incomplete, did you mean:

"which a complex expression didn't produce,"?

Ah, thank you, good catch. I meant that a complex expression is not a value-like expression (in this context) -- it's corrected now.

@saem
Copy link
Collaborator

saem commented Aug 18, 2024

/merge

Copy link

Merge requested by: @saem

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


@chore-runner chore-runner bot added this pull request to the merge queue Aug 18, 2024
Merged via the queue into nim-works:devel with commit 3cab673 Aug 18, 2024
35 checks passed
@zerbina zerbina deleted the fix-destructor-injection-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/backend Related to backend system of the compiler
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Missing =destroy call for discarded complex expressions
2 participants