Skip to content

Commit

Permalink
Shoe horn first updates for return syntax error from top-level as wel…
Browse files Browse the repository at this point in the history
…l as

fixing a bug with inDef noticing it is still inDef after evaluating a nested
def.
  • Loading branch information
enebo committed Mar 28, 2018
1 parent 3242f49 commit a6d4ec3
Show file tree
Hide file tree
Showing 5 changed files with 4,903 additions and 4,754 deletions.
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/lexer/yacc/SyntaxException.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public enum PID {
NUL_IN_SYMBOL("NUL_IN_SYMBOL"),
REGEXP_ENCODING_MISMATCH("REGEXP_ENCODING_MISMATCH"),
INVALID_MULTIBYTE_CHAR("INVALID_MULTIBYTE_CHAR"),
RATIONAL_OUT_OF_RANGE("RATIONAL_OUT_OF_RANGE")
RATIONAL_OUT_OF_RANGE("RATIONAL_OUT_OF_RANGE"),
TOP_LEVEL_RETURN("TOP_LEVEL_RETURN")
;

private String id;
Expand Down
22 changes: 22 additions & 0 deletions core/src/main/java/org/jruby/parser/ParserSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public class ParserSupport {
// Is the parser currently within a method definition
private boolean inDefinition;

// Is the parser currently within a class body.
private boolean inClass;

protected IRubyWarnings warnings;

protected ParserConfiguration configuration;
Expand Down Expand Up @@ -1050,6 +1053,25 @@ public void setInDef(boolean inDef) {
this.inDefinition = inDef;
}

public boolean isInClass() {
return inClass;
}

public void setIsInClass(boolean inClass) {
this.inClass = inClass;
}

/**
* Is the top of this scope a block scope (which happens in evals).
* This is supposed to serve same purpose as MRIs: dyna_in_block but
* I don't quite get why it is so complicated. All non-eval parsers
* have local scopes except eval but they combine in_main || compile_for_eval?
*/
public boolean isBlockTopLevel() {
return getConfiguration().isEvalParse();
}


/** Getter for property inSingle.
* @return Value of property inSingle.
*/
Expand Down

0 comments on commit a6d4ec3

Please sign in to comment.