Skip to content

fix: broken C emitted when re-assigning a unit-typed variable - #1573

Merged
eriksvedang merged 1 commit into
carp-lang:masterfrom
iwami4438:fix-emit-broken-c
Aug 3, 2026
Merged

fix: broken C emitted when re-assigning a unit-typed variable#1573
eriksvedang merged 1 commit into
carp-lang:masterfrom
iwami4438:fix-emit-broken-c

Conversation

@iwami4438

Copy link
Copy Markdown
Contributor
  • 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 (Emit.hs 624~)
  • Added a regression test
  • Ref: Reassigning unit values emits broken C #1542

- 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 hellerve left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@iwami4438

Copy link
Copy Markdown
Contributor Author

Thank you for the review, and sorry for the extra digging it caused.
From now on, I'll use git commit --no-verify to keep the reformat separate from the logic change.

@hellerve

Copy link
Copy Markdown
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.

@iwami4438

Copy link
Copy Markdown
Contributor Author

I'm using the version I installed this way. stack install ormolu
However, it does feel a little intrusive.
For reference, here's the version I'm using:

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

@eriksvedang
eriksvedang merged commit d718653 into carp-lang:master Aug 3, 2026
4 checks passed
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.

3 participants