Skip to content

Underscore does not work as expected #6518

Open

Description

@vanillajonathan

What happened?

I can do 0b11110000 and 0b_11110000 but not 0b1111_0000.

PRQL input

filter foo == 0b11110000  # Works
filter foo == 0b_11110000  # Works
filter foo == 0b1111_0000  # Does not work
filter foo == 0b1111_0000_1111_0000  # Does not work

SQL output

-

Expected SQL output

MVCE confirmation

  • Minimal example
  • New issue

Anything else?

I expect it to work like Python and Rust.

fn main() {
    println!("Hello, world! {}", 0x1111_0000);
}

Activity

  1. added
    bug
    on Nov 1, 2026
  2. prql-bot commented on Nov 1, 2026

    @prql-bot
    Collaborator

    Reproduced on main: 0b1111_0000 lexes as 0b1111 followed by the identifier _0000, so compilation fails with Unknown name _0000. The same happens with 0x and 0o (e.g. 0xdead_beef). The prefixed-number lexer accepted one optional _ right after the prefix and then digits only (lexer/mod.rs), unlike decimal literals, which allow _ anywhere after the first digit.

    A fix is on branch fix/issue-6518 (commit 1a4d919). After the first digit it accepts digits or _, and it strips underscores before parsing, so 0b1111_0000_1111_0000 compiles to 61680. The new cases in lexer::test::numbers fail without the change and pass with it. I couldn't open the PR because the bot's PR/issue creation allowance is exhausted until 2026-11-02T06:45Z (tracked in #6519). A maintainer can open a PR from the branch, or a later run can open it once the allowance resets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions