Skip to content

Special case meson.version().version_compare() in ternaries also - #16139

Open
QuLogic wants to merge 1 commit into
mesonbuild:masterfrom
QuLogic:ternary-version
Open

Special case meson.version().version_compare() in ternaries also#16139
QuLogic wants to merge 1 commit into
mesonbuild:masterfrom
QuLogic:ternary-version

Conversation

@QuLogic

@QuLogic QuLogic commented Aug 23, 2026

Copy link
Copy Markdown
Member

This is a corollary to #7594, but in ternaries.

Also fix some typos in the test case's comments.

@QuLogic
QuLogic requested a review from jpakkane as a code owner August 23, 2026 20:56
Comment on lines +428 to 434
prev_meson_version = mesonlib.project_meson_versions[self.subproject]
if self.tmp_meson_version and isinstance(prev_meson_version, mesonlib.Range):
always = prev_meson_version.always(self.tmp_meson_version)
if always is not None:
mlog.warning(f"Conditional on version '{self.tmp_meson_version}' always evaluates to {str(always).lower()}",
location=self.current_node)
if result_bool:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be a function, like

if self.tmp_meson_version:
    prev_meson_version = set_project_meson_version(self.subproject, self.tmp_meson_version)
try:
    if result_bool:
        return self.evaluate_statement(node.trueblock)
finally:
    mesonlib.project_meson_versions[self.subproject] = prev_meson_version

So that there are just 3-4 lines of copied code between ?: and if evaluation.

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