Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Const-folding does not const-fold NaN values #118

Copy link
Copy link
@mqyhlkahu

Description

@mqyhlkahu
Issue body actions

From src/python_minifier/transforms/constant_folding.py, lines 51-54:

        if isinstance(original_value, float) and math.isnan(original_value):
            # There is no nan literal.
            # we could use float('nan'), but that complicates folding as it's not a Constant
            return node

NaN values do actually have a representation, at least in all the Python versions that I tested (3.9 through 3.12):

>>> ast.unparse(ast.Constant(float("nan")))
'(1e309-1e309)'

This is because inf - inf = nan and 1e309 is inf.

Should be an easy fix, but I don't know if Python 2 supports the same thing so I didn't want to send a PR myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.