Skip to content

Commit 7c8f3d5

Browse files
committed
Remove unused methods and code review updates
1 parent 3283b64 commit 7c8f3d5

File tree

10 files changed

+16
-25
lines changed

10 files changed

+16
-25
lines changed

spec/tags/core/kernel/eval_tags.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ fails:Kernel#eval unwinds through a Proc-style closure and returns from a lambda
44
slow:Kernel#eval raises a LocalJumpError if there is no lambda-style closure in the chain
55
slow:Kernel#eval does not share locals across eval scopes
66
fails(cannot store constant with name in binary encoding):Kernel#eval with a magic encoding comment ignores the magic encoding comment if it is after a frozen_string_literal magic comment
7+
fails:Kernel#eval with a magic encoding comment ignores the frozen_string_literal magic comment if it appears after a token and warns if $VERBOSE is true
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
fails:Numbered parameters warns when numbered parameter is overwritten with local variable
1+
fails(GR-30031):Numbered parameters warns when numbered parameter is overwritten with local variable

src/main/java/org/truffleruby/aot/ParserCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private static RootParseNode parse(RubySource source) {
6666
.parseToJRubyAST(null, source, staticScope, parserConfiguration, rubyWarnings);
6767
if (!rubyWarnings.warnings.isEmpty()) {
6868
throw new RuntimeException("Core files should not emit warnings: " + String.join(
69-
", ",
69+
"\n",
7070
rubyWarnings.warnings.stream().map(w -> w.getWarningMessage()).collect(Collectors.toList())));
7171
}
7272
return rootParseNode;

src/main/java/org/truffleruby/language/methods/CatchForMethodNode.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ public Object execute(VirtualFrame frame) {
5555
}
5656
}
5757

58-
public RubyNode getBody() {
59-
return body;
60-
}
61-
6258
@Override
6359
public RubyNode simplifyAsTailExpression() {
6460
return new CatchForMethodNode(returnID, body.simplifyAsTailExpression()).copySourceSection(this);

src/main/java/org/truffleruby/language/methods/CatchNextNode.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ public CatchNextNode(RubyNode body) {
2626
this.body = body;
2727
}
2828

29-
public RubyNode getBody() {
30-
return body;
31-
}
32-
3329
@Override
3430
public Object execute(VirtualFrame frame) {
3531
try {

src/main/java/org/truffleruby/language/methods/CatchRetryAsErrorNode.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,4 @@ public Object execute(VirtualFrame frame) {
3737
}
3838
}
3939

40-
public RubyNode getBody() {
41-
return body;
42-
}
43-
4440
}

src/main/java/org/truffleruby/language/methods/ExceptionTranslatingNode.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ public Object execute(VirtualFrame frame) {
4040
}
4141
}
4242

43-
public RubyNode getChild() {
44-
return child;
45-
}
46-
4743
@Override
4844
public RubyNode simplifyAsTailExpression() {
4945
return new ExceptionTranslatingNode(child.simplifyAsTailExpression(), unsupportedOperationBehavior)

src/main/java/org/truffleruby/parser/RubyDeferredWarnings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public WarningMessage(Verbosity verbosity, String fileName, Integer lineNumber,
5959
}
6060

6161
public String getWarningMessage() {
62-
StringBuilder buffer = new StringBuilder(100);
62+
StringBuilder buffer = new StringBuilder();
6363
if (fileName != null) {
6464
buffer.append(fileName);
6565
if (lineNumber != null) {

src/main/java/org/truffleruby/parser/RubyWarnings.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void warn(String fileName, int lineNumber, String message) {
6969
return;
7070
}
7171

72-
StringBuilder buffer = new StringBuilder(100);
72+
StringBuilder buffer = new StringBuilder();
7373

7474
buffer.append(fileName).append(':').append(lineNumber).append(": ");
7575
buffer.append("warning: ").append(message).append('\n');
@@ -82,7 +82,7 @@ public void warn(String fileName, String message) {
8282
return;
8383
}
8484

85-
StringBuilder buffer = new StringBuilder(100);
85+
StringBuilder buffer = new StringBuilder();
8686

8787
if (fileName != null) {
8888
buffer.append(fileName).append(' ');

src/main/java/org/truffleruby/parser/lexer/RubyLexer.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -851,10 +851,16 @@ private int yylex() {
851851
case '#': { /* it's a comment */
852852
this.tokenSeen = tokenSeen;
853853

854-
// Always scan for magic comments, verbosity is not known at this time.
855-
if (!parser_magic_comment(lexb, lex_p, lex_pend - lex_p, parserRopeOperations, this)) {
856-
if (comment_at_top()) {
857-
set_file_encoding(lex_p, lex_pend);
854+
// There are no magic comments that can affect any runtime options after a token has been seen, so there's
855+
// no point in looking for them. However, if warnings are enabled, this should, but does not, scan for
856+
// the magic comment so we can report that it will be ignored. It does not warn for verbose because
857+
// verbose is not known at this point and we don't want to remove the tokenSeen check because it would
858+
// affect lexer performance.
859+
if (!tokenSeen) {
860+
if (!parser_magic_comment(lexb, lex_p, lex_pend - lex_p, parserRopeOperations, this)) {
861+
if (comment_at_top()) {
862+
set_file_encoding(lex_p, lex_pend);
863+
}
858864
}
859865
}
860866

0 commit comments

Comments
 (0)