Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions lib/rubygems/specification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ def self._load(str)
spec.instance_variable_set :@authors, array[12]
spec.instance_variable_set :@description, array[13]
spec.instance_variable_set :@homepage, array[14]
spec.instance_variable_set :@has_rdoc, array[15]
# offset due to has_rdoc removal
spec.instance_variable_set :@licenses, array[17]
spec.instance_variable_set :@metadata, array[18]
spec.instance_variable_set :@loaded, false
Expand Down Expand Up @@ -1884,29 +1884,6 @@ def gems_dir
@gems_dir ||= File.join(base_dir, "gems")
end

##
# Deprecated and ignored, defaults to true.
#
# Formerly used to indicate this gem was RDoc-capable.

def has_rdoc # :nodoc:
true
end
rubygems_deprecate :has_rdoc

##
# Deprecated and ignored.
#
# Formerly used to indicate this gem was RDoc-capable.

def has_rdoc=(ignored) # :nodoc:
@has_rdoc = true
end
rubygems_deprecate :has_rdoc=

alias_method :has_rdoc?, :has_rdoc # :nodoc:
rubygems_deprecate :has_rdoc?

##
# True if this gem has files in test_files

Expand Down Expand Up @@ -2399,7 +2376,6 @@ def to_ruby
:required_rubygems_version,
:specification_version,
:version,
:has_rdoc,
:metadata,
:signing_key,
]
Expand Down
32 changes: 29 additions & 3 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ struct lex_context {
BITFIELD(enum rb_parser_shareability, shareable_constant_value, 2);
BITFIELD(enum rescue_context, in_rescue, 2);
unsigned int cant_return: 1;
unsigned int in_alt_pattern: 1;
unsigned int capture_in_pattern: 1;
};

typedef struct RNode_DEF_TEMP rb_node_def_temp_t;
Expand Down Expand Up @@ -3473,6 +3475,8 @@ expr : command_call
pop_pktbl(p, $p_pktbl);
pop_pvtbl(p, $p_pvtbl);
p->ctxt.in_kwarg = $ctxt.in_kwarg;
p->ctxt.in_alt_pattern = $ctxt.in_alt_pattern;
p->ctxt.capture_in_pattern = $ctxt.capture_in_pattern;
$$ = NEW_CASE3($arg, NEW_IN($body, 0, 0, &@body, &NULL_LOC, &NULL_LOC, &@2), &@$, &NULL_LOC, &NULL_LOC);
/*% ripper: case!($:arg, in!($:body, Qnil, Qnil)) %*/
}
Expand All @@ -3486,6 +3490,8 @@ expr : command_call
pop_pktbl(p, $p_pktbl);
pop_pvtbl(p, $p_pvtbl);
p->ctxt.in_kwarg = $ctxt.in_kwarg;
p->ctxt.in_alt_pattern = $ctxt.in_alt_pattern;
p->ctxt.capture_in_pattern = $ctxt.capture_in_pattern;
$$ = NEW_CASE3($arg, NEW_IN($body, NEW_TRUE(&@body), NEW_FALSE(&@body), &@body, &@keyword_in, &NULL_LOC, &NULL_LOC), &@$, &NULL_LOC, &NULL_LOC);
/*% ripper: case!($:arg, in!($:body, Qnil, Qnil)) %*/
}
Expand Down Expand Up @@ -5389,6 +5395,8 @@ p_in_kwarg : {
SET_LEX_STATE(EXPR_BEG|EXPR_LABEL);
p->command_start = FALSE;
p->ctxt.in_kwarg = 1;
p->ctxt.in_alt_pattern = 0;
p->ctxt.capture_in_pattern = 0;
}
;

Expand All @@ -5399,6 +5407,8 @@ p_case_body : keyword_in
pop_pktbl(p, $p_pktbl);
pop_pvtbl(p, $p_pvtbl);
p->ctxt.in_kwarg = $ctxt.in_kwarg;
p->ctxt.in_alt_pattern = $ctxt.in_alt_pattern;
p->ctxt.capture_in_pattern = $ctxt.capture_in_pattern;
}
compstmt(stmts)
p_cases[cases]
Expand Down Expand Up @@ -5458,6 +5468,11 @@ p_top_expr_body : p_expr
;

p_expr : p_as
{
p->ctxt.in_alt_pattern = 0;
p->ctxt.capture_in_pattern = 0;
$$ = $1;
}
;

p_as : p_expr tASSOC p_variable
Expand All @@ -5470,10 +5485,17 @@ p_as : p_expr tASSOC p_variable
| p_alt
;

p_alt : p_alt '|' p_expr_basic
p_alt : p_alt[left] '|'[alt]
{
$$ = NEW_OR($1, $3, &@$, &@2);
/*% ripper: binary!($:1, ID2VAL(idOr), $:3) %*/
p->ctxt.in_alt_pattern = 1;
}
p_expr_basic[right]
{
if (p->ctxt.capture_in_pattern) {
yyerror1(&@alt, "alternative pattern after variable capture");
}
$$ = NEW_OR($left, $right, &@$, &@alt);
/*% ripper: binary!($:left, ID2VAL(idOr), $:right) %*/
}
| p_expr_basic
;
Expand Down Expand Up @@ -14697,7 +14719,11 @@ error_duplicate_pattern_variable(struct parser_params *p, ID id, const YYLTYPE *
if (st_is_member(p->pvtbl, id)) {
yyerror1(loc, "duplicated variable name");
}
else if (p->ctxt.in_alt_pattern && id) {
yyerror1(loc, "variable capture in alternative pattern");
}
else {
p->ctxt.capture_in_pattern = 1;
st_insert(p->pvtbl, (st_data_t)id, 0);
}
}
Expand Down
2 changes: 2 additions & 0 deletions prism/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,10 @@ errors:
- PARAMETER_UNEXPECTED_FWD
- PARAMETER_UNEXPECTED_NO_KW
- PARAMETER_WILD_LOOSE_COMMA
- PATTERN_ALTERNATIVE_AFTER_CAPTURE
- PATTERN_ARRAY_MULTIPLE_RESTS
- PATTERN_CAPTURE_DUPLICATE
- PATTERN_CAPTURE_IN_ALTERNATIVE
- PATTERN_EXPRESSION_AFTER_BRACKET
- PATTERN_EXPRESSION_AFTER_COMMA
- PATTERN_EXPRESSION_AFTER_HROCKET
Expand Down
Loading