Skip to content

Numbers may not have a leading zero #8037

Closed
@dvirf1

Description

@dvirf1

While reading through the Scanner class I noticed that it emits an error when non-zero numbers have a leading zero.
e.g 1, 3.14 and 42d are valid literals, and 01, 03.14, 042d, 00042d are invalid, resulting in a compilation error:

Non-zero numbers may not have a leading zero.

This makes sense, and according to the main objectives of Scala 3 it is expected that this behavior will be consistent with zero numbers.
e.g 0, 0.0, 0d should be valid and 00, 00.0, 00d should be invalid.
When trying this in the REPL, this is already the behavior (which makes since because isDigit('0') yields true), and only the message ("non-zero numbers ..") is wrong.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions