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: 7210eb1075e6
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c617dcfe5296
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Feb 15, 2015

  1. Copy the full SHA
    6028da2 View commit details
  2. [Truffle] Untagged some passing specs now that SyntaxErrors report co…

    …rrect line numbers with detailed source positions.
    nirvdrum committed Feb 15, 2015
    Copy the full SHA
    c617dcf View commit details
9 changes: 8 additions & 1 deletion core/src/main/java/org/jruby/parser/Parser.java
Original file line number Diff line number Diff line change
@@ -127,9 +127,16 @@ public Node parse(String file, LexerSource lexerSource, DynamicScope blockScope,
case NOT_ASCII_COMPATIBLE:
throw runtime.newArgumentError(e.getMessage());
default:
int line = e.getPosition().getLine();

// Detailed source positions always have the right line number so they don't need to be adjusted.
if (! (e.getPosition() instanceof DetailedSourcePosition)) {
line++;
}

StringBuilder buffer = new StringBuilder(100);
buffer.append(e.getPosition().getFile()).append(':');
buffer.append(e.getPosition().getLine() + 1).append(": ");
buffer.append(line).append(": ");
buffer.append(e.getMessage());

throw runtime.newSyntaxError(buffer.toString());
Original file line number Diff line number Diff line change
@@ -165,6 +165,17 @@ public void testRegression2() {
// assertEquals(8, position.getLength());
}

public void testSyntaxError() {
try {
parse("3.to_i(\n");
} catch (org.jruby.exceptions.RaiseException e) {
final String syntaxErrorMessage = e.getException().message.asJavaString();

// There's no easy way to get at the source position information, but it is embedded in the syntax error message.
assertEquals("test:1: syntax error, unexpected end-of-file\n", syntaxErrorMessage);
}
}

private class FoundException extends RuntimeException {

private final Node node;
1 change: 0 additions & 1 deletion spec/truffle/tags/core/kernel/eval_tags.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
fails:Kernel#eval evaluates within the scope of the eval
fails:Kernel#eval evaluates such that consts are scoped to the class of the eval
fails:Kernel#eval sets constants at the toplevel from inside a block
fails:Kernel#eval uses the filename of the binding if none is provided
fails:Kernel#eval uses the receiver as self inside the eval
fails:Kernel#eval returns from the scope calling #eval when evaluating 'return'
2 changes: 0 additions & 2 deletions spec/truffle/tags/rubysl/rubysl-erb/spec/filename_tags.txt

This file was deleted.