Skip to content

Commit d03c357

Browse files
authored
Merge pull request #5505 from headius/update_stdlib_2.5
Update stdlib to Ruby 2.5.3.
2 parents 8249863 + 7ef7efb commit d03c357

File tree

141 files changed

+1876
-401
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+1876
-401
lines changed

core/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ DO NOT MODIFIY - GENERATED CODE
6161
<test.results.dir>${build.dir}/test-results</test.results.dir>
6262
<tzdata.scope>provided</tzdata.scope>
6363
<tzdata.version>2013d</tzdata.version>
64-
<version.ruby>2.5.0</version.ruby>
64+
<version.ruby>2.5.3</version.ruby>
6565
<version.ruby.major>2.5</version.ruby.major>
66-
<version.ruby.minor>0</version.ruby.minor>
67-
<version.ruby.revision>60928</version.ruby.revision>
66+
<version.ruby.minor>3</version.ruby.minor>
67+
<version.ruby.revision>66309</version.ruby.revision>
6868
</properties>
6969
<dependencies>
7070
<dependency>

core/src/main/java/org/jruby/Ruby.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import org.jruby.ir.IRScope;
6060
import org.jruby.ir.IRScriptBody;
6161
import org.jruby.ir.instructions.Instr;
62+
import org.jruby.ir.runtime.IRWrappedLambdaReturnValue;
6263
import org.jruby.javasupport.JavaSupport;
6364
import org.jruby.javasupport.JavaSupportImpl;
6465
import org.jruby.lexer.yacc.ISourcePosition;
@@ -3325,6 +3326,16 @@ public void tearDown(boolean systemExit) {
33253326
}
33263327
// Reset $! now that rj has been handled
33273328
// context.runtime.getGlobalVariables().set("$!", oldExc);
3329+
} catch (IRWrappedLambdaReturnValue e) {
3330+
// This is partially similar to code in eval_error.c:error_handle but with less actual cases.
3331+
// IR treats END blocks are closures and as such we see this special non-local return jump type
3332+
// bubble this far out as we exec each END proc.
3333+
String filename = proc.getBlock().getBinding().filename;
3334+
if (e.isReturn()) {
3335+
getWarnings().warn(filename, "unexpected return");
3336+
} else {
3337+
getWarnings().warn(filename, "break from proc-closure");
3338+
}
33283339
}
33293340
}
33303341

core/src/main/java/org/jruby/RubyArray.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4669,6 +4669,21 @@ public IRubyObject sumCommon(final ThreadContext context, IRubyObject init, fina
46694669
} else {
46704670
break float_loop;
46714671
}
4672+
4673+
if (Double.isNaN(f)) continue;
4674+
if (Double.isNaN(x)) {
4675+
f = x;
4676+
continue;
4677+
}
4678+
if (Double.isInfinite(x)) {
4679+
if (Double.isInfinite(f) && Math.signum(x) != Math.signum(f))
4680+
f = Double.NaN;
4681+
else
4682+
f = x;
4683+
continue;
4684+
}
4685+
if (Double.isInfinite(f)) continue;
4686+
46724687
t = f + x;
46734688
if (Math.abs(f) >= Math.abs(x)) {
46744689
c += ((f - t) + x);

core/src/main/java/org/jruby/RubyBasicObject.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,6 +2178,17 @@ public IRubyObject taint(ThreadContext context) {
21782178
return this;
21792179
}
21802180

2181+
/**
2182+
* Set the object tainted and return it. This version does not check if the object has been frozen or if it is
2183+
* already tainted.
2184+
*
2185+
* @return
2186+
*/
2187+
IRubyObject tainted() {
2188+
setTaint(true);
2189+
return this;
2190+
}
2191+
21812192
@Deprecated
21822193
protected final void taint(Ruby runtime) {
21832194
taint(runtime.getCurrentContext());

core/src/main/java/org/jruby/RubyEnumerable.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,21 @@ public static IRubyObject sumAdd(final ThreadContext ctx, IRubyObject lhs, IRuby
10071007
return lhs.callMethod(ctx, "+", rhs);
10081008
}
10091009

1010+
Ruby runtime = ctx.runtime;
1011+
1012+
if (Double.isNaN(f)) return lhs;
1013+
if (Double.isNaN(x)) {
1014+
return lhs;
1015+
}
1016+
if (Double.isInfinite(x)) {
1017+
if (Double.isInfinite(f) && Math.signum(x) != Math.signum(f)) {
1018+
return new RubyFloat(runtime, RubyFloat.NAN);
1019+
} else {
1020+
return rhs;
1021+
}
1022+
}
1023+
if (Double.isInfinite(f)) return lhs;
1024+
10101025
// Kahan's compensated summation algorithm
10111026
t = f + x;
10121027
if (Math.abs(f) >= Math.abs(x)) {
@@ -1016,7 +1031,7 @@ public static IRubyObject sumAdd(final ThreadContext ctx, IRubyObject lhs, IRuby
10161031
}
10171032
f = t;
10181033

1019-
return new RubyFloat(ctx.runtime, f);
1034+
return new RubyFloat(runtime, f);
10201035
}
10211036

10221037
public static IRubyObject injectCommon(final ThreadContext context, IRubyObject self, IRubyObject init, final Block block) {

core/src/main/java/org/jruby/RubyFile.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ public IRubyObject fileOpenGeneric(ThreadContext context, IRubyObject filename,
14751475

14761476
// mri: FilePathValue/rb_get_path/rb_get_patch_check
14771477
public static RubyString get_path(ThreadContext context, IRubyObject path) {
1478-
if (path instanceof RubyString) return (RubyString) path;
1478+
if (path instanceof RubyString) return StringSupport.checkEmbeddedNulls(context.runtime, path);
14791479

14801480
FileSites sites = sites(context);
14811481
if (sites.respond_to_to_path.respondsTo(context, path, path, true)) path = sites.to_path.call(context, path, path);
@@ -1486,6 +1486,8 @@ public static RubyString get_path(ThreadContext context, IRubyObject path) {
14861486
// FIXME: MRI skips this logic on windows? Does not make sense to me why so I left it in.
14871487
// mri: file_path_convert
14881488
private static RubyString filePathConvert(ThreadContext context, RubyString path) {
1489+
StringSupport.checkEmbeddedNulls(context.runtime, path.convertToString());
1490+
14891491
if (!Platform.IS_WINDOWS) {
14901492
Ruby runtime = context.getRuntime();
14911493
EncodingService encodingService = runtime.getEncodingService();

core/src/main/java/org/jruby/RubyGlobal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public static void initARGV(Ruby runtime) {
9494
String[] argv = runtime.getInstanceConfig().getArgv();
9595

9696
for (String arg : argv) {
97-
argvArray.append(RubyString.newInternalFromJavaExternal(runtime, arg));
97+
argvArray.append(RubyString.newInternalFromJavaExternal(runtime, arg).tainted());
9898
}
9999

100100
if (runtime.getObject().getConstantNoConstMissing("ARGV") != null) {

core/src/main/java/org/jruby/RubyHash.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,10 +1515,14 @@ public IRubyObject transform_values(final ThreadContext context, final Block blo
15151515
public IRubyObject transform_keys_bang(final ThreadContext context, final Block block) {
15161516
if (block.isGiven()) {
15171517
testFrozen("Hash");
1518-
RubyArray keys = keys(context);
1519-
Arrays.stream(keys.toJavaArrayMaybeUnsafe()).forEach((key) -> {
1520-
op_aset(context, block.yield(context, key), delete(context, key));
1521-
});
1518+
RubyArray pairs = (RubyArray) flatten(context);
1519+
clear();
1520+
for (int i = 0; i < pairs.size(); i += 2) {
1521+
IRubyObject key = pairs.eltOk(i);
1522+
IRubyObject newKey = block.yield(context, key);
1523+
IRubyObject value = pairs.eltOk(i + 1);
1524+
op_aset(context, newKey, value);
1525+
}
15221526
return this;
15231527
}
15241528

core/src/main/java/org/jruby/RubyKernel.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,14 +1258,18 @@ static IRubyObject warn(ThreadContext context, IRubyObject recv, RubyString mess
12581258
@JRubyMethod(module = true, rest = true, visibility = PRIVATE)
12591259
public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
12601260
boolean kwargs = false;
1261-
int uplevel = -1;
1261+
int uplevel = 0;
12621262

12631263
if (args.length > 1) {
12641264
IRubyObject tmp = TypeConverter.checkHashType(context.runtime, args[args.length - 1]);
12651265
if (tmp != context.nil) {
12661266
kwargs = true;
12671267
IRubyObject[] rets = ArgsUtil.extractKeywordArgs(context, (RubyHash) tmp, WARN_VALID_KEYS);
12681268
uplevel = rets[0] == UNDEF ? 0 : RubyNumeric.num2int(rets[0]);
1269+
1270+
if (uplevel < 0) {
1271+
throw context.runtime.newArgumentError("negative level (" + uplevel + ")");
1272+
}
12691273
}
12701274
}
12711275

core/src/main/java/org/jruby/RubyModule.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4384,7 +4384,9 @@ public IRubyObject fetchConstant(String name, boolean includePrivate) {
43844384
if (entry == null) return null;
43854385

43864386
if (entry.hidden && !includePrivate) {
4387-
throw getRuntime().newNameError("private constant " + getName() + "::" + name + " referenced", name);
4387+
RubyModule recv = this;
4388+
if (recv.isIncluded()) recv = recv.getNonIncludedClass();
4389+
throw getRuntime().newNameError("private constant " + getName() + "::" + name + " referenced", recv, name);
43884390
}
43894391
if (entry.deprecated) {
43904392
final Ruby runtime = getRuntime();

0 commit comments

Comments
 (0)