Skip to content

zend_ast: Fix float literals losing precision in AST export - #25461

Closed
jorgsowa wants to merge 1 commit into
php:PHP-8.6from
jorgsowa:fix-ast-export-float-precision
Closed

jorgsowa wants to merge 1 commit into
php:PHP-8.6from
jorgsowa:fix-ast-export-float-precision

Conversation

@jorgsowa

Copy link
Copy Markdown
Contributor

zend_ast_export_zval() used the precision INI setting, so e.g. assert() messages showed 0.30000000000000004 as 0.3. Use the shortest round-trip representation instead.

zend_ast_export_zval() used the precision INI setting, so e.g. assert()
messages showed 0.30000000000000004 as 0.3. Use the shortest round-trip
representation instead.
@jorgsowa jorgsowa self-assigned this Nov 14, 2026

@iliaal iliaal 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.

LGTM

@iliaal

iliaal commented Nov 16, 2026

Copy link
Copy Markdown
Member

One inconsistency this leaves: reflection prints literal defaults through smart_str_append_scalar(), which still uses precision. So for function f($a = 0.30000000000000004, $b = FOO + 0.30000000000000004), ReflectionParameter now shows $a = 0.3 but $b = FOO + 0.30000000000000004. Fine as a follow-up in reflection's default value formatting, not a blocker here.

@jorgsowa jorgsowa closed this in 6debfb4 Nov 25, 2026
arnaud-lb added a commit to mihaliak/php-src that referenced this pull request Nov 25, 2026
* PHP-8.6:
  Fix float literals losing precision in AST export (phpGH-25461)
  ext/session: don't follow symlinked subdirectories in files GC (phpGH-25671)
arnaud-lb added a commit to prateekbhujel/php-src that referenced this pull request Nov 25, 2026
* PHP-8.6: (92 commits)
  Fix arrow functions not capturing variables in partial application args (php#25732)
  Fix float literals losing precision in AST export (phpGH-25461)
  ext/session: don't follow symlinked subdirectories in files GC (phpGH-25671)
  [skip ci] Skip automatic_worker_limit.phpt on few cores
  [skip ci] Fix Symfony test without USE_TRACKED_ALLOC
  [skip ci] Skip assign_dim_undef_op_data_008.phpt when JIT is unavailable
  ext/intl: Preserve the previous MessageFormatter pattern on failure (php#25642)
  Fix phpGH-25313: Assertion !EG(exception) in ZEND_FE_FREE when unpacking a generator into a by-ref parameter throws
  ext/opcache: Fix JIT register allocation for ASSIGN to traced reference
  Fix phpGH-25650: PDO::query() reports wrong argument numbers for ctor args
  Fix tracing JIT taking the wrong branch after a VM interrupt (php#25636)
  [skip ci] Add APP_DEBUG=0 for Symfony Preloading test
  streams: fix stale readbuflen after stream_filter_remove() on a read filter
  Update NEWS for phpGH-20920 LibreSSL build fix
  Fix phpGH-20920: do not use OPENSSL_strndup() for peer CN matching
  Simplify php_openssl_load_all_certs_from_file()
  Fix phpGH-20920: only register PKCS7_NO_DUAL_CONTENT when it is defined
  Fix phpGH-20920: guard ENGINE_cleanup() with OPENSSL_NO_ENGINE again
  ext/soap: Fix NULL dereference on empty Body with matching SOAPAction (phpGH-25661)
  ext/dom: Fix use-after-free in getElementById() after removing an ID attribute
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants