Skip to content

Conversation

@Keno
Copy link
Member

@Keno Keno commented Nov 22, 2025

Hex float literals like 0x1p3 should not be allowed to be followed by decimal digits or decimal points, as this creates confusing implicit multiplication that looks like a malformed literal. This change makes the parser reject expressions like 0x1p3.2 (previously parsed as 0x1p3 * 0.2) as invalid numeric constants, consistent with the existing restriction on juxtaposing hex integer literals.

Fixes #60189. Written by Claude (obviously - since it's set as the author - trying out the new web thing).

I figure this situation is rare enough and bad enough that we should just change this unconditionally across syntax versions, but if preferred, we could make use of syntax evolution for this (although we'd have to start versioning the lexer).

Hex float literals like 0x1p3 should not be allowed to be followed by
decimal digits or decimal points, as this creates confusing implicit
multiplication that looks like a malformed literal. This change makes
the parser reject expressions like 0x1p3.2 (previously parsed as
0x1p3 * 0.2) as invalid numeric constants, consistent with the existing
restriction on juxtaposing hex integer literals.

Fixes #60189
@Keno Keno requested review from c42f and mlechu November 22, 2025 00:38
@Keno Keno added parser Language parsing and surface syntax minor change Marginal behavior change acceptable for a minor release bugfix This change fixes an existing bug and removed minor change Marginal behavior change acceptable for a minor release labels Nov 22, 2025
@Keno
Copy link
Member Author

Keno commented Nov 22, 2025

I figure this situation is rare enough and bad enough that we should just change this unconditionally across syntax versions, but if preferred, we could make use of syntax evolution for this (although we'd have to start versioning the lexer).

Claude tells me flisp already has this fix, so indeed this is a bugfix, not a minor change.

keno@demeter6:~$ JULIA_USE_FLISP_PARSER=1 julia
        Info A new `nightly` version is available. Install with `juliaup update`.
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.14.0-DEV.81 (2025-11-13)
 _/ |\__'_|_|_|\__'_|  |  Commit f5f4c0174ed (8 days old master)
|__/                   |

julia> 0x1p3.2
ERROR: syntax: invalid numeric constant "0x1p3."
Stacktrace:
 [1] top-level scope
   @ REPL:1

julia> 
keno@demeter6:~$ julia
        Info A new `nightly` version is available. Install with `juliaup update`.
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.14.0-DEV.81 (2025-11-13)
 _/ |\__'_|_|_|\__'_|  |  Commit f5f4c0174ed (8 days old master)
|__/                   |

julia> 0x1p3.2
1.6

@Keno Keno merged commit 363d45c into master Nov 22, 2025
13 checks passed
@Keno Keno deleted the claude/fix-julia-60189-015Euj36eYVMc3qnRr6ctbND branch November 22, 2025 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix This change fixes an existing bug parser Language parsing and surface syntax

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hex float literals juxtaposed with decimal floats

4 participants