Skip to content

Float literals outside range of data type invalid in macro code #15482

Open
@BlobCodes

Description

Bug Report

Crystal currently allows writing arbitrarily large literals for floating types:

puts 2e999 # => Infinity

However, the same isn't true for macro code.
There, crystal uses the String#to_f* methods to parse integer literals.
Since these methods raise when the output would exceed the data type's precision, they also can't be parsed there:

{% puts 2e999 %} # => 2e999
{% puts 2e999 * 1 %} # => Error: Invalid Float64: "2e999"

Expected behaviour

I would expect numbers of the same type to behave exactly the same in crystal code and macro code.

Metadata

Assignees

No one assigned

    Labels

    kind:bugA bug in the code. Does not apply to documentation, specs, etc.topic:lang:macros

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions