Skip to content

Commit 20eca83

Browse files
authored
Merge pull request #4208 from Earlopain/reverse-sync
Reverse sync
2 parents 32455d1 + 8bfb5f7 commit 20eca83

6 files changed

Lines changed: 57 additions & 28 deletions

File tree

.github/workflows/documentation.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ jobs:
2929
run: |
3030
sudo apt-get update
3131
sudo apt-get install doxygen graphviz
32-
- name: Generate the templates
33-
run: bundle exec rake templates
3432
- name: Check ruby coverage
3533
run: bundle exec rake rdoc:coverage
3634
- name: Check C coverage

Gemfile.lock

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ GEM
88
specs:
99
ast (2.4.3)
1010
benchmark-ips (2.14.0)
11-
date (3.5.1)
12-
date (3.5.1-java)
13-
erb (6.0.2)
14-
erb (6.0.2-java)
11+
erb (6.0.7)
12+
erb (6.0.7-java)
1513
ffi (1.17.3)
1614
ffi (1.17.3-aarch64-linux-gnu)
1715
ffi (1.17.3-aarch64-linux-musl)
@@ -26,7 +24,8 @@ GEM
2624
prism (>= 1.3.0)
2725
rdoc (>= 4.0.0)
2826
reline (>= 0.4.2)
29-
jar-dependencies (0.5.5)
27+
jar-dependencies (0.5.7)
28+
logger (1.7.0)
3029
lrama (0.8.0)
3130
mini_portile2 (2.8.9)
3231
nokogiri (1.19.1)
@@ -54,21 +53,25 @@ GEM
5453
pp (0.6.3)
5554
prettyprint
5655
prettyprint (0.2.0)
57-
psych (5.3.1)
58-
date
59-
stringio
60-
psych (5.3.1-java)
61-
date
62-
jar-dependencies (>= 0.1.7)
6356
racc (1.8.1)
6457
racc (1.8.1-java)
6558
rake (13.3.1)
6659
rake-compiler (1.3.1)
6760
rake
6861
rake-compiler-dock (1.12.0)
69-
rdoc (7.2.0)
62+
rbs (4.1.3)
63+
logger
64+
prism (>= 1.6.0)
65+
tsort
66+
rbs (4.1.3-java)
67+
jar-dependencies (>= 0.1.7)
68+
logger
69+
prism (>= 1.6.0)
70+
tsort
71+
rdoc (8.0.0)
7072
erb
71-
psych (>= 4.0.0)
73+
prism (>= 1.6.0)
74+
rbs (>= 4.0.0)
7275
tsort
7376
reline (0.6.3)
7477
io-console (~> 0.5)
@@ -78,7 +81,6 @@ GEM
7881
racc (~> 1.5)
7982
sexp_processor (~> 4.16)
8083
sexp_processor (4.17.5)
81-
stringio (3.2.0)
8284
test-unit (3.7.7)
8385
power_assert
8486
tsort (0.2.0)

lib/prism/node_ext.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ def full_message_loc
386386
end
387387
end
388388

389+
# :stopdoc:
389390
class InNode < Node
390391
#: () -> String
391392
def in # :nodoc
@@ -487,4 +488,5 @@ def closing_loc # :nodoc
487488
end_keyword_loc
488489
end
489490
end
491+
# :startdoc:
490492
end

lib/prism/translation/ruby_parser.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,7 @@ def visit_write_value(node)
16271627
# Optional scopes to pass to the parser.
16281628
attr_reader :scopes #: Array[Array[Symbol]]?
16291629

1630+
# :nodoc:
16301631
#: (?scopes: Array[Array[Symbol]]?) -> void
16311632
def initialize(scopes: nil)
16321633
super()

rakelib/rdoc.rake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,8 @@ RDoc::Task.new(:rdoc) do |rdoc|
2626
)
2727
end
2828

29-
Rake::Task["rdoc"].prerequisites.unshift("templates")
29+
%w[rdoc rerdoc rdoc:coverage].each do |name|
30+
# rdoc:coverage available in rdoc as a default gem since ruby 3.3 only
31+
next unless Rake::Task.task_defined?(name)
32+
Rake::Task[name].enhance(["compile"])
33+
end

src/prism.c

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,20 @@ pm_version(void) {
135135
#define PM_NODE_LENGTH_SET_TOKEN(parser_, node_, token_) (PM_NODE_LENGTH(node_) = PM_TOKEN_END(parser_, token_) - PM_NODE_START(node_))
136136
#define PM_NODE_LENGTH_SET_LOCATION(node_, location_) (PM_NODE_LENGTH(node_) = PM_LOCATION_END(location_) - PM_NODE_START(node_))
137137

138-
#define PM_LOCATION_INIT(start_, length_) ((pm_location_t) { .start = (start_), .length = (length_) })
138+
/**
139+
* A function instead of a compound literal: MSVC 19.16 (VS2017) miscompiles a
140+
* conditional expression whose arms are both struct compound literals — it
141+
* materializes both arms before testing the condition, so the token
142+
* dereferences in the unselected arm of NTOK2LOC and friends fault on NULL.
143+
* Function call arguments are only evaluated on the selected branch.
144+
*/
145+
static PRISM_INLINE pm_location_t
146+
pm_location_init(uint32_t start, uint32_t length) {
147+
pm_location_t location = { .start = start, .length = length };
148+
return location;
149+
}
150+
151+
#define PM_LOCATION_INIT(start_, length_) pm_location_init((start_), (length_))
139152
#define PM_LOCATION_INIT_UNSET PM_LOCATION_INIT(0, 0)
140153
#define PM_LOCATION_INIT_TOKEN(parser_, token_) PM_LOCATION_INIT(PM_TOKEN_START(parser_, token_), PM_TOKEN_LENGTH(token_))
141154
#define PM_LOCATION_INIT_NODE(node_) UP(node_)->location
@@ -5670,12 +5683,15 @@ pm_match_write_node_create(pm_parser_t *parser, pm_call_node_t *call) {
56705683
*/
56715684
static pm_module_node_t *
56725685
pm_module_node_create(pm_parser_t *parser, pm_constant_id_list_t *locals, const pm_token_t *module_keyword, pm_node_t *constant_path, const pm_token_t *name, pm_node_t *body, const pm_token_t *end_keyword) {
5686+
pm_constant_id_list_t module_locals = { .ids = NULL, .size = 0, .capacity = 0 };
5687+
if (locals != NULL) module_locals = *locals;
5688+
56735689
return pm_module_node_new(
56745690
parser->arena,
56755691
++parser->node_id,
56765692
0,
56775693
PM_LOCATION_INIT_TOKENS(parser, module_keyword, end_keyword),
5678-
(locals == NULL ? ((pm_constant_id_list_t) { .ids = NULL, .size = 0, .capacity = 0 }) : *locals),
5694+
module_locals,
56795695
TOK2LOC(parser, module_keyword),
56805696
constant_path,
56815697
body,
@@ -17033,10 +17049,11 @@ parse_pattern_rest(pm_parser_t *parser, pm_constant_id_list_t *captures) {
1703317049
pm_parser_local_add(parser, constant_id, parser->previous.start, parser->previous.end, 0);
1703417050
}
1703517051

17036-
parse_pattern_capture(parser, captures, constant_id, &TOK2LOC(parser, &parser->previous));
17052+
pm_location_t previous_loc = TOK2LOC(parser, &parser->previous);
17053+
parse_pattern_capture(parser, captures, constant_id, &previous_loc);
1703717054
name = UP(pm_local_variable_target_node_create(
1703817055
parser,
17039-
&TOK2LOC(parser, &parser->previous),
17056+
&previous_loc,
1704017057
constant_id,
1704117058
(uint32_t) (depth == -1 ? 0 : depth)
1704217059
));
@@ -17069,10 +17086,11 @@ parse_pattern_keyword_rest(pm_parser_t *parser, pm_constant_id_list_t *captures)
1706917086
pm_parser_local_add(parser, constant_id, parser->previous.start, parser->previous.end, 0);
1707017087
}
1707117088

17072-
parse_pattern_capture(parser, captures, constant_id, &TOK2LOC(parser, &parser->previous));
17089+
pm_location_t previous_loc = TOK2LOC(parser, &parser->previous);
17090+
parse_pattern_capture(parser, captures, constant_id, &previous_loc);
1707317091
value = UP(pm_local_variable_target_node_create(
1707417092
parser,
17075-
&TOK2LOC(parser, &parser->previous),
17093+
&previous_loc,
1707617094
constant_id,
1707717095
(uint32_t) (depth == -1 ? 0 : depth)
1707817096
));
@@ -17316,10 +17334,11 @@ parse_pattern_primitive(pm_parser_t *parser, pm_constant_id_list_t *captures, pm
1731617334
pm_parser_local_add(parser, constant_id, parser->previous.start, parser->previous.end, 0);
1731717335
}
1731817336

17319-
parse_pattern_capture(parser, captures, constant_id, &TOK2LOC(parser, &parser->previous));
17337+
pm_location_t previous_loc = TOK2LOC(parser, &parser->previous);
17338+
parse_pattern_capture(parser, captures, constant_id, &previous_loc);
1732017339
return UP(pm_local_variable_target_node_create(
1732117340
parser,
17322-
&TOK2LOC(parser, &parser->previous),
17341+
&previous_loc,
1732317342
constant_id,
1732417343
(uint32_t) (depth == -1 ? 0 : depth)
1732517344
));
@@ -17668,10 +17687,11 @@ parse_pattern_primitives(pm_parser_t *parser, pm_constant_id_list_t *captures, p
1766817687
pm_parser_local_add(parser, constant_id, parser->previous.start, parser->previous.end, 0);
1766917688
}
1767017689

17671-
parse_pattern_capture(parser, captures, constant_id, &TOK2LOC(parser, &parser->previous));
17690+
pm_location_t previous_loc = TOK2LOC(parser, &parser->previous);
17691+
parse_pattern_capture(parser, captures, constant_id, &previous_loc);
1767217692
pm_local_variable_target_node_t *target = pm_local_variable_target_node_create(
1767317693
parser,
17674-
&TOK2LOC(parser, &parser->previous),
17694+
&previous_loc,
1767517695
constant_id,
1767617696
(uint32_t) (depth == -1 ? 0 : depth)
1767717697
);
@@ -21459,7 +21479,9 @@ parse_regular_expression_named_capture(pm_parser_t *parser, const pm_string_t *c
2145921479

2146021480
// Next, create the local variable target and add it to the list of
2146121481
// targets for the match.
21462-
pm_node_t *target = UP(pm_local_variable_target_node_create(parser, &TOK2LOC(parser, &((pm_token_t) { .type = 0, .start = start, .end = end })), name, depth == -1 ? 0 : (uint32_t) depth));
21482+
pm_token_t token = { .type = 0, .start = start, .end = end };
21483+
pm_location_t token_loc = TOK2LOC(parser, &token);
21484+
pm_node_t *target = UP(pm_local_variable_target_node_create(parser, &token_loc, name, depth == -1 ? 0 : (uint32_t) depth));
2146321485
pm_node_list_append(parser->arena, &callback_data->match->targets, target);
2146421486
}
2146521487

0 commit comments

Comments
 (0)