Skip to main content
FORGEJO ERA / ISSUE #605

Numeric constants with negative exponents, long constants, and precise operands are mishandled

closedOpened by MelanX on

Original description​

By MelanX · October 23, 2026

Crate: tools/minecraft-options

Commit: 2b2af1e4f8166d02e4732d19e040a53745d97a51

Behavior

  • M_FLOAT uses the character class [\d.eE+], which has no -, so float 1.0E-5f and double 1.0E-4d (javap switches to scientific notation below 1e-3) never match. NaN and Infinity do not match either. const_num returns None and arithmetic_chain silently drops the operand, giving a wrong transform with no error. For an encode/decode pair both directions lose the same step, so the invert_ops equality check still accepts it.
  • const_int and const_num never read ldc2_w longs or lconst_*.
  • formula() renders operands with :g (six significant digits), so 0.33333334 becomes 0.333333 and 1234567 becomes 1.23457e+06. The dataset regexes accept the truncated value.

Expected behavior

Constants are parsed completely and rendered with their exact value (repr), and an operand that cannot be parsed makes the transform unresolved.

Impact

No current release triggers it (the cache holds only the operations -70 and /40), but a future transform could be shipped with a changed scale and high confidence.

Locations

  • tools/minecraft-options/analyze_options.py M_FLOAT (245), const_int/const_num (330-362), formula (380-388)
  • tools/minecraft-options/dataset.py _AFFINE/_OFFSET (69-70)

Validation and limitations

M_FLOAT.match("float 1.0E-5f") is None; formula produced (x * 0.333333) and (x - 123.457) in scratch runs.