Skip to content

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

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

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.

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