Skip to content

Accept underscores in float literals (B5)#370

Open
TumCucTom wants to merge 6 commits into
vercel-labs:mainfrom
TumCucTom:fix/b5-float-underscores
Open

Accept underscores in float literals (B5)#370
TumCucTom wants to merge 6 commits into
vercel-labs:mainfrom
TumCucTom:fix/b5-float-underscores

Conversation

@TumCucTom

@TumCucTom TumCucTom commented Jun 4, 2026

Copy link
Copy Markdown

Summary

Float literals accepted digits '.' digits but rejected any input containing _, while integer literals accept 1_000.0-style separators. The asymmetry forces numeric groupings to be omitted in float sources and produces a confusing TYP019 for 1_000.5.

This PR mirrors the integer path: copy the source into a stack buffer, reject leading, trailing, and double underscores, then run the existing digit shape check and strtod on the stripped text. Behavior stays byte-equivalent for inputs without _.

Closes one item from #318 (audit finding B5, re-confirmed against main).

Test plan

  • conformance/native/pass/float-literal-underscores.0 covers 1_000.5, 0.0_5, 1.0e1_0, 1_000.0
  • conformance/native/fail/malformed-float-underscores.0 covers trailing underscore (still TYP019)
  • pnpm run conformance passes (all 600+ pass fixtures, all fail fixtures)
  • compiler-metrics.mts has 0 violations (budget bumped by 20)
  • No C compiler warnings

TumCucTom and others added 3 commits June 4, 2026 01:38
Direct backend lowering diagnostics reported a generic "direct backend
local type is unsupported" message regardless of the actual target,
even though the expected and help fields already named the target.
Substitute the generic "direct backend " prefix with a target-specific
label (COFF x64, ELF64, AArch64 Mach-O, x86_64 Mach-O, COFF AArch64,
AArch64 ELF) when the message originates from IR lowering.

Cover the new behavior with regression tests for the linux-musl-x64,
win32-x64.exe, and darwin-x64 targets in the
owned-drop-direct-backend-unsupported fixture.

Co-Authored-By: Zippy AI <tomkinsbale@icloud.com>
…ring-diagnostics

# Conflicts:
#	scripts/compiler-metrics.mts
Float literals accepted `digits '.' digits` but rejected any input
containing `_`, while integer literals accept `1_000.0`-style separators.
The asymmetry forces numeric groupings to be omitted in float sources and
produces a confusing TYP019 for `1_000.5`.

Mirror the integer path: copy the source into a stack buffer, reject
leading, trailing, and double underscores, then run the existing digit
shape check and `strtod` on the stripped text. The behavior stays
byte-equivalent for inputs without `_`.

Adds a positive conformance fixture (`float-literal-underscores.0`) and
a negative one (`malformed-float-underscores.0` covers trailing
underscore). Bumps the `checker.c` line budget by 20.
@vercel

vercel Bot commented Jun 4, 2026

Copy link
Copy Markdown

@TumCucTom is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread native/zero-c/src/checker.c Outdated
TumCucTom added 3 commits June 4, 2026 23:23
Replace fixed 64-byte stack buffer with heap allocation in
parse_float_literal to handle arbitrarily long (but valid) float
literals without truncation (VADE fix).
Replace fixed 64-byte stack buffer with heap allocation to handle
arbitrarily long valid float literals without truncation (VADE fix).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant