fix: broken C emitted when re-assigning a unit-typed variable - #1573
Merged
Conversation
- set! always emitted an assignment, producing invalid C (`x = ;`) for unit-typed (()) variables, which have no C declaration - Now skipped as a no-op, matching declaration behavior - Added a regression test
hellerve
approved these changes
Jul 31, 2026
hellerve
left a comment
Member
There was a problem hiding this comment.
looks good, thanks! in the future it might be better to separate the reformat from the fix. i had to dig for a while to understand the magic is in src/Emit.hs:625.
Contributor
Author
|
Thank you for the review, and sorry for the extra digging it caused. |
Member
|
i wonder why my commit hooks don’t seem to fire the same way. we should revisit the ormolu setup in general i guess! i’ll open an issue. |
Contributor
Author
|
I'm using the version I installed this way. ormolu -v
ormolu 0.7.2.0
using ghc-lib-parser 9.6.7.20250325
stack --version
Version 3.11.1, Git revision 2352d78a8ac5b42d021c8064b8f64ac1c8b8b3d5 x86_64 hpack-0.39.6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
set!always emitted an assignment, producing invalid C (x = ;) for unit-typed (()) variables, which have no C declaration