Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a91d07651c29
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 60a231413603
Choose a head ref
  • 2 commits
  • 7 files changed
  • 1 contributor

Commits on Apr 18, 2017

  1. Fixes #4562. Ripper.sexp unexpectedly returns nil when given source i…

    …ncludes keyword-ish symbol.
    
    Weirdly 4 keywords was missing from the reswords production in the grammar
    file. Seemingly a single line got deleted at some point.
    enebo committed Apr 18, 2017
    Copy the full SHA
    2d2cec5 View commit details
  2. Copy the full SHA
    60a2314 View commit details
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/common/RubyWarnings.java
Original file line number Diff line number Diff line change
@@ -66,6 +66,7 @@ public boolean isVerbose() {
* Prints a warning, unless $VERBOSE is nil.
*/
@Override
@Deprecated
public void warn(ID id, ISourcePosition position, String message) {
if (!runtime.warningsEnabled()) return;

@@ -163,6 +164,7 @@ public void warning(ID id, String message) {
* Prints a warning, only in verbose mode.
*/
@Override
@Deprecated
public void warning(ID id, ISourcePosition position, String message) {
warning(id, position.getFile(), position.getLine() + 1, message);
}
1,562 changes: 783 additions & 779 deletions core/src/main/java/org/jruby/ext/ripper/RipperParser.java

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions core/src/main/java/org/jruby/ext/ripper/RipperParser.y
Original file line number Diff line number Diff line change
@@ -748,6 +748,7 @@ reswords : k__LINE__ | k__FILE__ | k__ENCODING__ | klBEGIN | klEND
| kFOR | kIN | kMODULE | kNEXT | kNIL | kNOT
| kOR | kREDO | kRESCUE | kRETRY | kRETURN | kSELF | kSUPER
| kTHEN | kTRUE | kUNDEF | kWHEN | kYIELD
| kIF | kUNLESS | kWHILE | kUNTIL
| kIF_MOD | kUNLESS_MOD | kWHILE_MOD | kUNTIL_MOD | kRESCUE_MOD

arg : lhs '=' arg {
Original file line number Diff line number Diff line change
@@ -331,6 +331,7 @@ public StackState getCmdArgumentState() {
}

public void compile_error(String message) {
System.out.println(getRuntime().newString(message));
dispatch("on_parse_error", getRuntime().newString(message));
}

7,976 changes: 4,020 additions & 3,956 deletions core/src/main/java/org/jruby/ext/ripper/YyTables.java

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions core/src/main/java/org/jruby/lexer/yacc/RubyLexer.java
Original file line number Diff line number Diff line change
@@ -142,8 +142,9 @@ private ComplexNode newComplexNode(NumericNode number) {
}

protected void ambiguousOperator(String op, String syn) {
warnings.warn(ID.AMBIGUOUS_ARGUMENT, getPosition(), "`" + op + "' after local variable or literal is interpreted as binary operator");
warnings.warn(ID.AMBIGUOUS_ARGUMENT, getPosition(), "even though it seems like " + syn);
warnings.warn(ID.AMBIGUOUS_ARGUMENT, getFile(), ruby_sourceline,
"`" + op + "' after local variable or literal is interpreted as binary operator");
warnings.warn(ID.AMBIGUOUS_ARGUMENT, getFile(), ruby_sourceline, "even though it seems like " + syn);
}

public enum Keyword {
@@ -450,7 +451,7 @@ private int getFloatToken(String number, int suffix) {
try {
d = SafeDoubleParser.parseDouble(number);
} catch (NumberFormatException e) {
warnings.warn(ID.FLOAT_OUT_OF_RANGE, getPosition(), "Float " + number + " out of range.");
warnings.warn(ID.FLOAT_OUT_OF_RANGE, getFile(), ruby_sourceline, "Float " + number + " out of range.");

d = number.startsWith("-") ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY;
}
@@ -665,7 +666,7 @@ private int hereDocumentIdentifier() throws IOException {

private boolean arg_ambiguous() {
if (warnings.isVerbose() && Options.PARSER_WARN_AMBIGUOUS_ARGUMENTS.load()) {
warnings.warning(ID.AMBIGUOUS_ARGUMENT, getPosition(), "Ambiguous first argument; make sure.");
warnings.warning(ID.AMBIGUOUS_ARGUMENT, getFile(), ruby_sourceline, "Ambiguous first argument; make sure.");
}
return true;
}
@@ -1103,7 +1104,7 @@ private int ampersand(boolean spaceSeen) throws IOException {
ISourcePosition tmpPosition = getPosition();
if (isSpaceArg(c, spaceSeen)) {
if (warnings.isVerbose() && Options.PARSER_WARN_ARGUMENT_PREFIX.load())
warnings.warning(ID.ARGUMENT_AS_PREFIX, tmpPosition, "`&' interpreted as argument prefix");
warnings.warning(ID.ARGUMENT_AS_PREFIX, getFile(), tmpPosition.getLine(), "`&' interpreted as argument prefix");
c = Tokens.tAMPER;
} else if (isBEG()) {
c = Tokens.tAMPER;
@@ -1839,7 +1840,7 @@ private int questionMark() throws IOException {
break;
}
if (c2 != 0) {
warnings.warn(ID.INVALID_CHAR_SEQUENCE, getPosition(), "invalid character syntax; use ?\\" + c2);
warnings.warn(ID.INVALID_CHAR_SEQUENCE, getFile(), ruby_sourceline, "invalid character syntax; use ?\\" + c2);
}
}
pushback(c);
@@ -1969,7 +1970,7 @@ private int star(boolean spaceSeen) throws IOException {

if (isSpaceArg(c, spaceSeen)) {
if (warnings.isVerbose() && Options.PARSER_WARN_ARGUMENT_PREFIX.load())
warnings.warning(ID.ARGUMENT_AS_PREFIX, getPosition(), "`**' interpreted as argument prefix");
warnings.warning(ID.ARGUMENT_AS_PREFIX, getFile(), ruby_sourceline, "`**' interpreted as argument prefix");
c = Tokens.tDSTAR;
} else if (isBEG()) {
c = Tokens.tDSTAR;
@@ -1986,7 +1987,7 @@ private int star(boolean spaceSeen) throws IOException {
pushback(c);
if (isSpaceArg(c, spaceSeen)) {
if (warnings.isVerbose() && Options.PARSER_WARN_ARGUMENT_PREFIX.load())
warnings.warning(ID.ARGUMENT_AS_PREFIX, getPosition(), "`*' interpreted as argument prefix");
warnings.warning(ID.ARGUMENT_AS_PREFIX, getFile(), ruby_sourceline, "`*' interpreted as argument prefix");
c = Tokens.tSTAR;
} else if (isBEG()) {
c = Tokens.tSTAR;
22 changes: 14 additions & 8 deletions core/src/main/java/org/jruby/parser/ParserSupport.java
Original file line number Diff line number Diff line change
@@ -239,7 +239,7 @@ public Node appendToBlock(Node head, Node tail) {
}

if (warnings.isVerbose() && isBreakStatement(((ListNode) head).getLast()) && Options.PARSER_WARN_NOT_REACHED.load()) {
warnings.warning(ID.STATEMENT_NOT_REACHED, tail.getPosition(), "statement not reached");
warnings.warning(ID.STATEMENT_NOT_REACHED, lexer.getFile(), tail.getPosition().getLine(), "statement not reached");
}

// Assumption: tail is never a list node
@@ -408,13 +408,17 @@ public boolean isBreakStatement(Node node) {

public void warnUnlessEOption(ID id, Node node, String message) {
if (!configuration.isInlineSource()) {
warnings.warn(id, node.getPosition(), message);
ISourcePosition pos = node.getPosition();

warnings.warn(id, lexer.getFile(), pos.getLine(), message);
}
}

public void warningUnlessEOption(ID id, Node node, String message) {
if (warnings.isVerbose() && !configuration.isInlineSource()) {
warnings.warning(id, node.getPosition(), message);
ISourcePosition pos = node.getPosition();

warnings.warning(id, lexer.getFile(), pos.getLine(), message);
}
}

@@ -467,7 +471,8 @@ public boolean isLiteral(Node node) {

private void handleUselessWarn(Node node, String useless) {
if (Options.PARSER_WARN_USELESSS_USE_OF.load()) {
warnings.warn(ID.USELESS_EXPRESSION, node.getPosition(), "Useless use of " + useless + " in void context.");
warnings.warn(ID.USELESS_EXPRESSION, lexer.getFile(), node.getPosition().getLine(),
"Useless use of " + useless + " in void context.");
}
}

@@ -554,7 +559,8 @@ private boolean checkAssignmentInCondition(Node node) {
} else if (node instanceof LocalAsgnNode || node instanceof DAsgnNode || node instanceof GlobalAsgnNode || node instanceof InstAsgnNode) {
Node valueNode = ((AssignableNode) node).getValueNode();
if (isStaticContent(valueNode)) {
warnings.warn(ID.ASSIGNMENT_IN_CONDITIONAL, node.getPosition(), "found = in conditional, should be ==");
warnings.warn(ID.ASSIGNMENT_IN_CONDITIONAL, lexer.getFile(), node.getPosition().getLine(),
"found = in conditional, should be ==");
}
return true;
}
@@ -1169,11 +1175,11 @@ public ISourcePosition getPosition(ISourcePositionHolder start) {
}

public void warn(ID id, ISourcePosition position, String message, Object... data) {
warnings.warn(id, position, message);
warnings.warn(id, lexer.getFile(), position.getLine(), message);
}

public void warning(ID id, ISourcePosition position, String message, Object... data) {
if (warnings.isVerbose()) warnings.warning(id, position, message);
if (warnings.isVerbose()) warnings.warning(id, lexer.getFile(), position.getLine(), message);
}

// ENEBO: Totally weird naming (in MRI is not allocated and is a local var name) [1.9]
@@ -1218,7 +1224,7 @@ public String shadowing_lvar(String name) {

if (current.isBlockScope() && warnings.isVerbose() && current.isDefined(name) >= 0 &&
Options.PARSER_WARN_LOCAL_SHADOWING.load()) {
warnings.warning(ID.STATEMENT_NOT_REACHED, lexer.getPosition(), "shadowing outer local variable - " + name);
warnings.warning(ID.STATEMENT_NOT_REACHED, lexer.getFile(), lexer.getPosition().getLine(), "shadowing outer local variable - " + name);
}

return name;