Skip to content

Parser: make condExpr work properly in const contexts#995

Open
ehaas wants to merge 2 commits intoVexu:masterfrom
ehaas:condexpr-prop
Open

Parser: make condExpr work properly in const contexts#995
ehaas wants to merge 2 commits intoVexu:masterfrom
ehaas:condexpr-prop

Conversation

@ehaas
Copy link
Copy Markdown
Collaborator

@ehaas ehaas commented Apr 17, 2026

If the condition and the selected branch of a condExpr are both statically known, make the condExpr have that statically known value. Also fixes parsing of binary conditional expressions (previous issues were masked by casting the result to void in binary expressions.c

I believe this should fix https://codeberg.org/ziglang/translate-c/issues/322

ehaas added 2 commits April 17, 2026 08:39
Don't eval during adjustTypes for condexpr if condition and selected branch are
"comptime known". This prevents type adjustment from clobbering the selected
value despite the alternative never being evaluated. If the "comptime known"
conditions are met, select the appropriate value as the value of the condexpr
@MasonRemaley
Copy link
Copy Markdown

Confirmed on my end!

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.

2 participants