Skip to content

Commit 0113a90

Browse files
committed
Change string for duplicated when warning
1 parent f633a05 commit 0113a90

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

core/src/main/java/org/jruby/ir/builder/IRBuilder.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import java.util.Set;
5454
import java.util.function.Consumer;
5555

56+
import static org.jruby.api.Warn.warning;
5657
import static org.jruby.ir.IRFlags.*;
5758
import static org.jruby.ir.builder.StringStyle.Frozen;
5859
import static org.jruby.ir.builder.StringStyle.Mutable;
@@ -2838,8 +2839,9 @@ protected boolean literalWhenCheck(U value, Set<IRubyObject> seenLiterals, Map<I
28382839

28392840
if (literal != null) {
28402841
if (seenLiterals.contains(literal)) {
2841-
getManager().getRuntime().getWarnings().warning(IRubyWarnings.ID.MISCELLANEOUS, getFileName(), getLine(value),
2842-
"duplicated 'when' clause with line " + (origLocs.get(literal) + 1) + " is ignored");
2842+
var context = manager.getRuntime().getCurrentContext();
2843+
warning(context, "'when' clause on line " + getLine(value) +
2844+
" duplicates 'when' clause on line " + (origLocs.get(literal) + 1) + " and is ignored");
28432845
return false;
28442846
} else {
28452847
seenLiterals.add(literal);

core/src/main/java/org/jruby/ir/builder/IRBuilderAST.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
import java.util.stream.Collectors;
6969
import java.util.stream.Stream;
7070

71+
import static org.jruby.api.Warn.warning;
7172
import static org.jruby.ir.builder.StringStyle.Frozen;
7273
import static org.jruby.ir.instructions.RuntimeHelperCall.Methods.*;
7374

@@ -1195,8 +1196,9 @@ private <T extends Node & ILiteralNode> Map<java.lang.Integer, Tuple<Operand, La
11951196
origTable.put((int) exprLong, whenNode);
11961197
nodeBodies.put(whenNode, bodyLabel);
11971198
} else {
1198-
getManager().getRuntime().getWarnings().warning(IRubyWarnings.ID.MISCELLANEOUS, getFileName(), expr.getLine() + 1,
1199-
"duplicated 'when' clause with line " + (origTable.get((int) exprLong).getLine() + 1) + " is ignored");
1199+
var context = getManager().getRuntime().getCurrentContext();
1200+
warning(context, "'when' clause on line " + (getLine(expr) + 1) +
1201+
" duplicates 'when' clause on line " + (origTable.get((int) exprLong).getLine() + 1) + " and is ignored");
12001202
}
12011203
}
12021204

core/src/main/java/org/jruby/parser/RubyParserBase.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,6 @@ public Node gettable2(Node node) {
286286

287287
if (currentScope.isBlockScope() && slot != -1) {
288288
if (isNumParamId(id) && isNumParamNested()) return null;
289-
if (name.getBytes().equals(lexer.getCurrentArg())) {
290-
compile_error(str(getRuntime(), "circular argument reference - ", name));
291-
}
292289

293290
Node newNode = new DVarNode(node.getLine(), slot, name);
294291

@@ -300,9 +297,6 @@ public Node gettable2(Node node) {
300297

301298
StaticScope.Type type = currentScope.getType();
302299
if (type == StaticScope.Type.LOCAL) {
303-
if (name.getBytes().equals(lexer.getCurrentArg())) {
304-
compile_error(str(getRuntime(), "circular argument reference - ", name));
305-
}
306300

307301
Node newNode = new LocalVarNode(node.getLine(), slot, name);
308302

@@ -388,9 +382,6 @@ public void numparam_name(ByteList name) {
388382

389383
public Node declareIdentifier(ByteList byteName) {
390384
RubySymbol name = symbolID(byteName);
391-
if (byteName.equals(lexer.getCurrentArg())) {
392-
compile_error(str(getRuntime(), "circular argument reference - ", name));
393-
}
394385

395386
String id = name.idString();
396387
boolean isNumParam = isNumParamId(id);

0 commit comments

Comments
 (0)