Skip to content

Language: comparison inside function call argument — var_dump($x !== false) binds as (var_dump($x)) !== false (Zend/zend_compile.c) #13694

Closed

Description

@PurHur

Category

language · php-src-strict

Problem

Comparison expressions passed as function call arguments parse with wrong precedence on VM: var_dump($x !== false) is compiled as (var_dump($x)) !== false instead of var_dump(($x !== false)).

Symptoms include false negatives in var_export($di !== false) while the same comparison in if ($di !== false) behaves correctly, and misleading maintainer repro output for otherwise-correct builtins.

php-src reference

Repro (verified 2026-06-29)

php -r 'var_dump(var_dump(1) !== false);'                    # Zend: int(1) bool(true)
php bin/vm.php -r 'var_dump(var_dump(1) !== false);'         # VM: int(1) bool(false)
php test/repro/maintainer_gap_date_interval_plus_separator.php
php bin/vm.php test/repro/maintainer_gap_date_interval_plus_separator.php

Minimal:

$di = date_interval_create_from_date_string('1 day + 2 hours');
var_export($di !== false); // Zend: true; VM: false (mis-parse)
if ($di !== false) { echo $di->format('%d days %h hours'); } // both OK

Scope (PHP-in-PHP first)

Layer Path
Parser / AST lib/Parser.php, lib/Compiler.php — call argument expression boundaries
VM emit lib/VM.php — !== must not leak outside arg slot

Done when (php-src-strict)

  • var_dump($expr !== false) dumps the boolean comparison result
  • test/repro/maintainer_gap_date_interval_plus_separator.php output matches Zend
  • No regression for assignment form $r = $x !== false

Verification

php bin/vm.php -r 'var_dump(var_dump(1) !== false);'
php bin/vm.php test/repro/maintainer_gap_date_interval_plus_separator.php

Links

Activity

  1. added
    enhancementNew feature or request
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 29, 2026
  2. PurHur commented on Jun 29, 2026

    @PurHur
    OwnerAuthor

    claim: worker-lane-c — batch (issues #13694)

  3. PurHur commented on Jun 29, 2026

    @PurHur
    OwnerAuthor

    Merged via #13701

    Verification

    • php bin/vm.php -r 'var_dump(var_dump(1) !== false);' → int(1) + bool(true)
    • php bin/vm.php test/repro/maintainer_gap_date_interval_plus_separator.php → true + formatted interval
    • ./vendor/bin/phpunit test/unit/InlineCallArgProducerSlotTest.php --filter testNotIdenticalInsideCallArgUsesComparisonSlot — OK
    • ./vendor/bin/phpunit test/compliance/VMTest.php --filter comparison_inside_call_arg — OK (Docker)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions