Skip to content

Map one and zero to true and false in bool expressions#290

Open
thedataking wants to merge 2 commits intomasterfrom
feature/bool_literals
Open

Map one and zero to true and false in bool expressions#290
thedataking wants to merge 2 commits intomasterfrom
feature/bool_literals

Conversation

@thedataking
Copy link
Copy Markdown
Contributor

No description provided.

@fw-immunant fw-immunant force-pushed the feature/bool_literals branch from c5a4e52 to 7b7f4f9 Compare August 21, 2025 18:23
@fw-immunant
Copy link
Copy Markdown
Contributor

I rebased this. It seems like a fairly straightforward bit of low-hanging fruit; we now transpile _Bool cond = 1; as let mut cond: bool = true; (as opposed to let mut cond: bool = 1 as std::ffi::c_int != 0;).

Copy link
Copy Markdown
Contributor

@kkysen kkysen left a comment

Choose a reason for hiding this comment

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

Can we wait until the const macro changes finish merging before this? I had been working on this as well but was trying to sequence it with the overlapping const macro work, and I didn't realize you were going to work on it at the same time as me.

@thedataking
Copy link
Copy Markdown
Contributor Author

@kkysen can this land now or is it obsoleted by your work?

Copy link
Copy Markdown
Contributor

@kkysen kkysen left a comment

Choose a reason for hiding this comment

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

@kkysen can this land now or is it obsoleted by your work?

Partially. This solution as-is doesn't work anymore, because we translate true as the const true_0: c_int now. I think it might be better to make that const true_0: bool, but leave the true_0/false_0, just like we leave type uint32_t = u32 instead of using u32 directly.

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