prism 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/src/regexp.c CHANGED
@@ -158,6 +158,11 @@ pm_regexp_parse_range_quantifier(pm_regexp_parser_t *parser) {
158
158
  } state = PM_REGEXP_RANGE_QUANTIFIER_STATE_START;
159
159
 
160
160
  while (1) {
161
+ if (parser->cursor >= parser->end) {
162
+ parser->cursor = savepoint;
163
+ return true;
164
+ }
165
+
161
166
  switch (state) {
162
167
  case PM_REGEXP_RANGE_QUANTIFIER_STATE_START:
163
168
  switch (*parser->cursor) {
@@ -594,8 +599,7 @@ pm_regexp_parse_group(pm_regexp_parser_t *parser, uint16_t depth) {
594
599
  // If we hit a -, then we're done parsing options.
595
600
  if (*parser->cursor != '-') break;
596
601
 
597
- // Otherwise, fallthrough to the - case.
598
- /* fallthrough */
602
+ PRISM_FALLTHROUGH
599
603
  case '-':
600
604
  parser->cursor++;
601
605
  while (!pm_regexp_char_is_eof(parser) && *parser->cursor != ':' && *parser->cursor != ')') {
@@ -707,7 +711,7 @@ pm_regexp_parse_item(pm_regexp_parser_t *parser, uint16_t depth) {
707
711
  if (!pm_regexp_char_find(parser, '\n')) parser->cursor = parser->end;
708
712
  return true;
709
713
  }
710
- /* fallthrough */
714
+ PRISM_FALLTHROUGH
711
715
  default: {
712
716
  size_t width;
713
717
  if (!parser->encoding_changed) {
data/src/serialize.c CHANGED
@@ -1916,6 +1916,12 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1916
1916
  case PM_UNTIL_NODE: {
1917
1917
  pm_buffer_append_varuint(buffer, (uint32_t) node->flags);
1918
1918
  pm_serialize_location(parser, &((pm_until_node_t *)node)->keyword_loc, buffer);
1919
+ if (((pm_until_node_t *)node)->do_keyword_loc.start == NULL) {
1920
+ pm_buffer_append_byte(buffer, 0);
1921
+ } else {
1922
+ pm_buffer_append_byte(buffer, 1);
1923
+ pm_serialize_location(parser, &((pm_until_node_t *)node)->do_keyword_loc, buffer);
1924
+ }
1919
1925
  if (((pm_until_node_t *)node)->closing_loc.start == NULL) {
1920
1926
  pm_buffer_append_byte(buffer, 0);
1921
1927
  } else {
@@ -1954,6 +1960,12 @@ pm_serialize_node(pm_parser_t *parser, pm_node_t *node, pm_buffer_t *buffer) {
1954
1960
  case PM_WHILE_NODE: {
1955
1961
  pm_buffer_append_varuint(buffer, (uint32_t) node->flags);
1956
1962
  pm_serialize_location(parser, &((pm_while_node_t *)node)->keyword_loc, buffer);
1963
+ if (((pm_while_node_t *)node)->do_keyword_loc.start == NULL) {
1964
+ pm_buffer_append_byte(buffer, 0);
1965
+ } else {
1966
+ pm_buffer_append_byte(buffer, 1);
1967
+ pm_serialize_location(parser, &((pm_while_node_t *)node)->do_keyword_loc, buffer);
1968
+ }
1957
1969
  if (((pm_while_node_t *)node)->closing_loc.start == NULL) {
1958
1970
  pm_buffer_append_byte(buffer, 0);
1959
1971
  } else {
@@ -501,7 +501,7 @@ pm_static_literal_inspect_node(pm_buffer_t *buffer, const pm_static_literals_met
501
501
  case PM_FLOAT_NODE: {
502
502
  const double value = ((const pm_float_node_t *) node)->value;
503
503
 
504
- if (isinf(value)) {
504
+ if (PRISM_ISINF(value)) {
505
505
  if (*node->location.start == '-') {
506
506
  pm_buffer_append_byte(buffer, '-');
507
507
  }
data/src/util/pm_char.c CHANGED
@@ -185,7 +185,7 @@ pm_strspn_number_kind_underscores(const uint8_t *string, ptrdiff_t length, const
185
185
  size++;
186
186
  }
187
187
 
188
- if (string[size - 1] == '_') *invalid = string + size - 1;
188
+ if (size > 0 && string[size - 1] == '_') *invalid = string + size - 1;
189
189
  return size;
190
190
  }
191
191
 
data/src/util/pm_string.c CHANGED
@@ -189,6 +189,7 @@ pm_string_mapped_init(pm_string_t *string, const char *filepath) {
189
189
 
190
190
  source = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
191
191
  if (source == MAP_FAILED) {
192
+ close(fd);
192
193
  return PM_STRING_INIT_ERROR_GENERIC;
193
194
  }
194
195
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prism
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-10 00:00:00.000000000 Z
11
+ date: 2024-12-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -39,6 +39,7 @@ files:
39
39
  - docs/parser_translation.md
40
40
  - docs/parsing_rules.md
41
41
  - docs/releasing.md
42
+ - docs/relocation.md
42
43
  - docs/ripper_translation.md
43
44
  - docs/ruby_api.md
44
45
  - docs/ruby_parser_translation.md
@@ -93,7 +94,9 @@ files:
93
94
  - lib/prism/polyfill/byteindex.rb
94
95
  - lib/prism/polyfill/unpack1.rb
95
96
  - lib/prism/reflection.rb
97
+ - lib/prism/relocation.rb
96
98
  - lib/prism/serialize.rb
99
+ - lib/prism/string_query.rb
97
100
  - lib/prism/translation.rb
98
101
  - lib/prism/translation/parser.rb
99
102
  - lib/prism/translation/parser/compiler.rb
@@ -114,6 +117,7 @@ files:
114
117
  - rbi/prism/node_ext.rbi
115
118
  - rbi/prism/parse_result.rbi
116
119
  - rbi/prism/reflection.rbi
120
+ - rbi/prism/string_query.rbi
117
121
  - rbi/prism/translation/parser.rbi
118
122
  - rbi/prism/translation/parser33.rbi
119
123
  - rbi/prism/translation/parser34.rbi
@@ -133,7 +137,9 @@ files:
133
137
  - sig/prism/parse_result.rbs
134
138
  - sig/prism/pattern.rbs
135
139
  - sig/prism/reflection.rbs
140
+ - sig/prism/relocation.rbs
136
141
  - sig/prism/serialize.rbs
142
+ - sig/prism/string_query.rbs
137
143
  - sig/prism/visitor.rbs
138
144
  - src/diagnostic.c
139
145
  - src/encoding.c
@@ -178,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
184
  - !ruby/object:Gem::Version
179
185
  version: '0'
180
186
  requirements: []
181
- rubygems_version: 3.6.0.dev
187
+ rubygems_version: 3.5.16
182
188
  signing_key:
183
189
  specification_version: 4
184
190
  summary: Prism Ruby parser