Skip to content

Tokenizer Bug: Floats with leading 0's wrong tokenized #8605

Open
@hsjobeki

Description

Describe the bug

As described in the Title, nix tokenizes floats with leading zeros differently.
The first part of the float is interpreted as an integer if it starts with a zero.

IEEE doesn't specify this, but usually, I would expect the implementation to take care of leading zeros. and interpret the number as just one number

  • double checked for similar issues.

Steps To Reproduce

nix repl

nix-repl> [ 01.1e2 ]
[ 1 10 ]

Which comes due to a fault in the tokenizer

01.1e2

Is tokenized into

TOKEN_INTEGER, "01"
TOKEN_FLOAT, ".1e2"

Expected behavior

01.1e2

This should produce only one token

TOKEN_FLOAT, "01.1e2"

Priorities

Add 👍 to issues you find important.

Metadata

Assignees

No one assigned

    Labels

    breakingChanges we can't make without breaking old expressions, changing hashes, etcbuglanguageThe Nix expression language; parser, interpreter, primops, evaluation, etc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions