You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Integer(o, exception: false) with an object that defines to_str parses the String it returns leniently, so trailing garbage is ignored and an invalid number gives an Integer instead of nil: "1---" gives 1, "12abc" gives 12, and "0x" and "0.0" give 0. The same Strings passed directly give nil, and CRuby gives nil for both. The docs say that with exception: false "an exception of any kind is suppressed and nil is returned" (Kernel#Integer); without exception: false, JRuby already raises ArgumentError for these objects as CRuby does.
JRuby 10.1.3.0 (jruby 10.1.3.0 (4.0.9) 2026-11-05 3db52d02f9 OpenJDK 64-Bit Server VM 21.0.13+9-LTS on 21.0.13+9-LTS +indy +jit [aarch64-linux]) and a build of master (54dd973) print the same.
After to_str, TypeConverter.convertToInteger calls ConvertBytes.byteListToInum(context.runtime, bytes, base, exception) (TypeConverter.java#L445; on master TypeConverter.java#L436). The last parameter of that 4-argument overload is badcheck, not exception (ConvertBytes.java#L365; on master ConvertBytes.java#L359), so exception: false turns off the check for trailing characters. CRuby's rb_convert_to_integer calls rb_str_convert_to_inum(tmp, base, TRUE, raise_exception) there (object.c#L3456); the 5-argument byteListToInum(runtime, bytes, base, true, exception) would match it.
Activity