Skip to content

Remove stale Float constants and add a constant drift test#2994

Open
zonuexe wants to merge 3 commits into
ruby:masterfrom
zonuexe:float-constant-drift
Open

Remove stale Float constants and add a constant drift test#2994
zonuexe wants to merge 3 commits into
ruby:masterfrom
zonuexe:float-constant-drift

Conversation

@zonuexe

@zonuexe zonuexe commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Removes two Float constants that are declared in core/float.rbs but raise NameError at runtime, and adds a test guarding against this kind of drift for platform-invariant core classes.

Removed constants

Constant drift test

test/stdlib/constant_drift_test.rb compares Module#constants(false) against the constants declared in the loaded RBS environment, for a curated set of platform/build-invariant core classes (Float, Integer, String, …). It fails in either direction:

  • stale — declared in RBS but no longer defined at runtime (e.g. the two constants above), or
  • missing — defined at runtime but absent from RBS.

Classes whose constant set varies by OS or build options (Process, Socket, Errno, …) are intentionally excluded, with a SKIP map for per-constant exceptions. Singleton constant type assertions for the remaining Float constants are added as well.

zonuexe added 3 commits June 16, 2026 11:01
Compares Module#constants(false) against the constants declared in the
loaded RBS environment for a curated set of platform/build-invariant
core classes (Float, Integer, String, ...), failing on either:

* stale   - declared in RBS but no longer defined at runtime, or
* missing - defined at runtime but absent from the RBS signature.

Classes whose constant set varies by OS or build options (Process,
Socket, Errno, ...) are intentionally excluded, with a SKIP map for
per-constant exceptions.
Both are declared in core/float.rbs but raise NameError at runtime:

* Float::ROUNDS was removed from Ruby in 3.0 (ruby/ruby#2953).
* Float::Infinity was added in ruby#1095 (which superseded ruby#1080). Ruby does
  not define this constant: looking at the Ruby of that period (3.1),
  numeric.c defines Float::INFINITY but not Float::Infinity, and it still
  raises NameError today.

Also add singleton constant type assertions for the remaining Float
constants, so their declared types stay verified against the runtime.
Integer::GMP_VERSION is defined only when Ruby is built with GMP
(USE_GMP), so it is present on the Linux CI build but absent on macOS.
Add it to the SKIP map so the gate stays green across platforms.
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