Skip to content

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

Merged
soutaro merged 4 commits into
ruby:masterfrom
zonuexe:float-constant-drift
Jul 27, 2026
Merged

Remove stale Float constants and add a constant drift test#2994
soutaro merged 4 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.
@soutaro soutaro added this to the RBS 4.1 milestone Jul 27, 2026
@soutaro
soutaro enabled auto-merge July 27, 2026 02:28

@soutaro soutaro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@soutaro
soutaro merged commit 0078d60 into ruby:master Jul 27, 2026
26 checks passed
@zonuexe
zonuexe deleted the float-constant-drift branch July 27, 2026 07:04
@soutaro soutaro added the Released PRs already included in the released version label Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Released PRs already included in the released version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants