prism 0.28.0 → 0.29.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7715842445523172c9593bae81ff5c1a889c6735b59f1c5a879fe63bbeacd724
4
- data.tar.gz: 755dd34f1e20f374aa2910482a8fac4e709e332d5313a1c80bcc2b3fc9ffbad4
3
+ metadata.gz: 4ac8167684c0f975fdba449e77206d97756f6c39f22ce871f79a79a61260503f
4
+ data.tar.gz: 6a2dd5c0a47df7c8c575ad2e5b344c789d548e93cfe82e5fa29974d46a52bb3c
5
5
  SHA512:
6
- metadata.gz: 37206e932b34156ad6b1679ea379e8665d987bf9673d37a1e5f74c1abb1a442adbdc0d2045d75624e60507794bd8dd56c5b7bbc8864d7ab9cec1f9a6c1c44b05
7
- data.tar.gz: 15fc69115a30581010fb65d540f8d2a0c0cd1f76d59754d9b3c1d2f4c2f4354f2f9cbb5087a7989df6b85ff5285248875d6ed40b05d2fca89753f1235948bb0d
6
+ metadata.gz: dfa7fe63285b85cb45aa0be681916d6891ee5e5adf2162ab5c18423417f7938afc99f00eca8fd6187fbd0b7168af088d932fbda3c1361d1c73953f39329bed70
7
+ data.tar.gz: 79bc51db60600d74a6bfbeae5eba3a8ec505e9809d0f7ff0b05563f1f7a8cd284cc293233397323a443217a4a5271f90b4c40516168ae3a8be0ddc2d7376cef9
data/CHANGELOG.md CHANGED
@@ -6,6 +6,24 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.29.0] - 2024-05-10
10
+
11
+ ### Added
12
+
13
+ - Added `Prism::CallNode#full_message_loc`, which gives the location including the `=` if there is one.
14
+ - A warning for when `# shareable_constant_value` is not used on its own line.
15
+ - An error for invalid implicit local variable writes.
16
+ - Implicit hash patterns in array patterns are disallowed.
17
+ - We now validate that Unicode escape sequences are not surrogates.
18
+
19
+ ### Changed
20
+
21
+ - All fields named `operator` have been renamed to `binary_operator` for `*OperatorWriteNode` nodes. This is to make it easier to provide C++ support. In the Ruby API, the old fields are aliased to the new fields with a deprecation warning.
22
+ - Many updated error messages to more closely match CRuby.
23
+ - We ensure keyword parameters do not end in `!` or `?`.
24
+ - Fixed some escaping in string literals with control sequences and hex escapes.
25
+ - Fix a bug with RBS types when used outside the `ruby/prism` codebase.
26
+
9
27
  ## [0.28.0] - 2024-05-03
10
28
 
11
29
  ### Added
@@ -500,7 +518,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
500
518
 
501
519
  - 🎉 Initial release! 🎉
502
520
 
503
- [unreleased]: https://github.com/ruby/prism/compare/v0.28.0...HEAD
521
+ [unreleased]: https://github.com/ruby/prism/compare/v0.29.0...HEAD
522
+ [0.29.0]: https://github.com/ruby/prism/compare/v0.28.0...v0.29.0
504
523
  [0.28.0]: https://github.com/ruby/prism/compare/v0.27.0...v0.28.0
505
524
  [0.27.0]: https://github.com/ruby/prism/compare/v0.26.0...v0.27.0
506
525
  [0.26.0]: https://github.com/ruby/prism/compare/v0.25.0...v0.26.0
data/config.yml CHANGED
@@ -7,13 +7,16 @@ errors:
7
7
  - ARGUMENT_BARE_HASH
8
8
  - ARGUMENT_BLOCK_FORWARDING
9
9
  - ARGUMENT_BLOCK_MULTI
10
+ - ARGUMENT_CONFLICT_AMPERSAND
11
+ - ARGUMENT_CONFLICT_STAR
12
+ - ARGUMENT_CONFLICT_STAR_STAR
10
13
  - ARGUMENT_FORMAL_CLASS
11
14
  - ARGUMENT_FORMAL_CONSTANT
12
15
  - ARGUMENT_FORMAL_GLOBAL
13
16
  - ARGUMENT_FORMAL_IVAR
14
17
  - ARGUMENT_FORWARDING_UNBOUND
15
18
  - ARGUMENT_IN
16
- - ARGUMENT_NO_FORWARDING_AMP
19
+ - ARGUMENT_NO_FORWARDING_AMPERSAND
17
20
  - ARGUMENT_NO_FORWARDING_ELLIPSES
18
21
  - ARGUMENT_NO_FORWARDING_STAR
19
22
  - ARGUMENT_NO_FORWARDING_STAR_STAR
@@ -95,6 +98,7 @@ errors:
95
98
  - EXPECT_EXPRESSION_AFTER_SPLAT_HASH
96
99
  - EXPECT_EXPRESSION_AFTER_STAR
97
100
  - EXPECT_IDENT_REQ_PARAMETER
101
+ - EXPECT_IN_DELIMITER
98
102
  - EXPECT_LPAREN_REQ_PARAMETER
99
103
  - EXPECT_MESSAGE
100
104
  - EXPECT_RBRACKET
@@ -134,6 +138,7 @@ errors:
134
138
  - INVALID_BLOCK_EXIT
135
139
  - INVALID_CHARACTER
136
140
  - INVALID_ENCODING_MAGIC_COMMENT
141
+ - INVALID_ESCAPE_CHARACTER
137
142
  - INVALID_FLOAT_EXPONENT
138
143
  - INVALID_LOCAL_VARIABLE_READ
139
144
  - INVALID_LOCAL_VARIABLE_WRITE
@@ -142,6 +147,7 @@ errors:
142
147
  - INVALID_MULTIBYTE_ESCAPE
143
148
  - INVALID_NUMBER_BINARY
144
149
  - INVALID_NUMBER_DECIMAL
150
+ - INVALID_NUMBER_FRACTION
145
151
  - INVALID_NUMBER_HEXADECIMAL
146
152
  - INVALID_NUMBER_OCTAL
147
153
  - INVALID_NUMBER_UNDERSCORE_INNER
@@ -187,6 +193,7 @@ errors:
187
193
  - PARAMETER_ASSOC_SPLAT_MULTI
188
194
  - PARAMETER_BLOCK_MULTI
189
195
  - PARAMETER_CIRCULAR
196
+ - PARAMETER_FORWARDING_AFTER_REST
190
197
  - PARAMETER_METHOD_NAME
191
198
  - PARAMETER_NAME_DUPLICATED
192
199
  - PARAMETER_NO_DEFAULT
@@ -209,8 +216,10 @@ errors:
209
216
  - PATTERN_EXPRESSION_AFTER_PIPE
210
217
  - PATTERN_EXPRESSION_AFTER_RANGE
211
218
  - PATTERN_EXPRESSION_AFTER_REST
219
+ - PATTERN_HASH_IMPLICIT
212
220
  - PATTERN_HASH_KEY
213
221
  - PATTERN_HASH_KEY_DUPLICATE
222
+ - PATTERN_HASH_KEY_INTERPOLATED
214
223
  - PATTERN_HASH_KEY_LABEL
215
224
  - PATTERN_HASH_KEY_LOCALS
216
225
  - PATTERN_IDENT_AFTER_HROCKET
@@ -286,6 +295,7 @@ warnings:
286
295
  - KEYWORD_EOL
287
296
  - LITERAL_IN_CONDITION_DEFAULT
288
297
  - LITERAL_IN_CONDITION_VERBOSE
298
+ - SHAREABLE_CONSTANT_VALUE_LINE
289
299
  - SHEBANG_CARRIAGE_RETURN
290
300
  - UNEXPECTED_CARRIAGE_RETURN
291
301
  - UNREACHABLE_STATEMENT
@@ -1203,9 +1213,9 @@ nodes:
1203
1213
  type: constant
1204
1214
  - name: write_name
1205
1215
  type: constant
1206
- - name: operator
1216
+ - name: binary_operator
1207
1217
  type: constant
1208
- - name: operator_loc
1218
+ - name: binary_operator_loc
1209
1219
  type: location
1210
1220
  - name: value
1211
1221
  type: node
@@ -1361,11 +1371,11 @@ nodes:
1361
1371
  type: constant
1362
1372
  - name: name_loc
1363
1373
  type: location
1364
- - name: operator_loc
1374
+ - name: binary_operator_loc
1365
1375
  type: location
1366
1376
  - name: value
1367
1377
  type: node
1368
- - name: operator
1378
+ - name: binary_operator
1369
1379
  type: constant
1370
1380
  comment: |
1371
1381
  Represents assigning to a class variable using an operator that isn't `=`.
@@ -1471,11 +1481,11 @@ nodes:
1471
1481
  type: constant
1472
1482
  - name: name_loc
1473
1483
  type: location
1474
- - name: operator_loc
1484
+ - name: binary_operator_loc
1475
1485
  type: location
1476
1486
  - name: value
1477
1487
  type: node
1478
- - name: operator
1488
+ - name: binary_operator
1479
1489
  type: constant
1480
1490
  comment: |
1481
1491
  Represents assigning to a constant using an operator that isn't `=`.
@@ -1559,11 +1569,11 @@ nodes:
1559
1569
  - name: target
1560
1570
  type: node
1561
1571
  kind: ConstantPathNode
1562
- - name: operator_loc
1572
+ - name: binary_operator_loc
1563
1573
  type: location
1564
1574
  - name: value
1565
1575
  type: node
1566
- - name: operator
1576
+ - name: binary_operator
1567
1577
  type: constant
1568
1578
  comment: |
1569
1579
  Represents assigning to a constant path using an operator that isn't `=`.
@@ -1930,11 +1940,11 @@ nodes:
1930
1940
  type: constant
1931
1941
  - name: name_loc
1932
1942
  type: location
1933
- - name: operator_loc
1943
+ - name: binary_operator_loc
1934
1944
  type: location
1935
1945
  - name: value
1936
1946
  type: node
1937
- - name: operator
1947
+ - name: binary_operator
1938
1948
  type: constant
1939
1949
  comment: |
1940
1950
  Represents assigning to a global variable using an operator that isn't `=`.
@@ -2266,9 +2276,9 @@ nodes:
2266
2276
  type: location
2267
2277
  - name: block
2268
2278
  type: node?
2269
- - name: operator
2279
+ - name: binary_operator
2270
2280
  type: constant
2271
- - name: operator_loc
2281
+ - name: binary_operator_loc
2272
2282
  type: location
2273
2283
  - name: value
2274
2284
  type: node
@@ -2354,11 +2364,11 @@ nodes:
2354
2364
  type: constant
2355
2365
  - name: name_loc
2356
2366
  type: location
2357
- - name: operator_loc
2367
+ - name: binary_operator_loc
2358
2368
  type: location
2359
2369
  - name: value
2360
2370
  type: node
2361
- - name: operator
2371
+ - name: binary_operator
2362
2372
  type: constant
2363
2373
  comment: |
2364
2374
  Represents assigning to an instance variable using an operator that isn't `=`.
@@ -2634,13 +2644,13 @@ nodes:
2634
2644
  fields:
2635
2645
  - name: name_loc
2636
2646
  type: location
2637
- - name: operator_loc
2647
+ - name: binary_operator_loc
2638
2648
  type: location
2639
2649
  - name: value
2640
2650
  type: node
2641
2651
  - name: name
2642
2652
  type: constant
2643
- - name: operator
2653
+ - name: binary_operator
2644
2654
  type: constant
2645
2655
  - name: depth
2646
2656
  type: uint32
@@ -3075,6 +3085,8 @@ nodes:
3075
3085
  # On parsing error of `f(**kwargs, ...)` or `f(**nil, ...)`, the keyword_rest value is moved here:
3076
3086
  - KeywordRestParameterNode
3077
3087
  - NoKeywordsParameterNode
3088
+ # On parsing error of `f(..., ...)`, the first forwarding parameter is moved here:
3089
+ - ForwardingParameterNode
3078
3090
  - name: keywords
3079
3091
  type: node[]
3080
3092
  kind:
data/ext/prism/api_node.c CHANGED
@@ -1708,14 +1708,14 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
1708
1708
  assert(cast->write_name != 0);
1709
1709
  argv[6] = RARRAY_AREF(constants, cast->write_name - 1);
1710
1710
 
1711
- // operator
1711
+ // binary_operator
1712
1712
  #line 198 "api_node.c.erb"
1713
- assert(cast->operator != 0);
1714
- argv[7] = RARRAY_AREF(constants, cast->operator - 1);
1713
+ assert(cast->binary_operator != 0);
1714
+ argv[7] = RARRAY_AREF(constants, cast->binary_operator - 1);
1715
1715
 
1716
- // operator_loc
1716
+ // binary_operator_loc
1717
1717
  #line 211 "api_node.c.erb"
1718
- argv[8] = pm_location_new(parser, cast->operator_loc.start, cast->operator_loc.end);
1718
+ argv[8] = pm_location_new(parser, cast->binary_operator_loc.start, cast->binary_operator_loc.end);
1719
1719
 
1720
1720
  // value
1721
1721
  #line 186 "api_node.c.erb"
@@ -2009,18 +2009,18 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
2009
2009
  #line 211 "api_node.c.erb"
2010
2010
  argv[2] = pm_location_new(parser, cast->name_loc.start, cast->name_loc.end);
2011
2011
 
2012
- // operator_loc
2012
+ // binary_operator_loc
2013
2013
  #line 211 "api_node.c.erb"
2014
- argv[3] = pm_location_new(parser, cast->operator_loc.start, cast->operator_loc.end);
2014
+ argv[3] = pm_location_new(parser, cast->binary_operator_loc.start, cast->binary_operator_loc.end);
2015
2015
 
2016
2016
  // value
2017
2017
  #line 186 "api_node.c.erb"
2018
2018
  argv[4] = rb_ary_pop(value_stack);
2019
2019
 
2020
- // operator
2020
+ // binary_operator
2021
2021
  #line 198 "api_node.c.erb"
2022
- assert(cast->operator != 0);
2023
- argv[5] = RARRAY_AREF(constants, cast->operator - 1);
2022
+ assert(cast->binary_operator != 0);
2023
+ argv[5] = RARRAY_AREF(constants, cast->binary_operator - 1);
2024
2024
 
2025
2025
  // location
2026
2026
  argv[6] = pm_location_new(parser, node->location.start, node->location.end);
@@ -2176,18 +2176,18 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
2176
2176
  #line 211 "api_node.c.erb"
2177
2177
  argv[2] = pm_location_new(parser, cast->name_loc.start, cast->name_loc.end);
2178
2178
 
2179
- // operator_loc
2179
+ // binary_operator_loc
2180
2180
  #line 211 "api_node.c.erb"
2181
- argv[3] = pm_location_new(parser, cast->operator_loc.start, cast->operator_loc.end);
2181
+ argv[3] = pm_location_new(parser, cast->binary_operator_loc.start, cast->binary_operator_loc.end);
2182
2182
 
2183
2183
  // value
2184
2184
  #line 186 "api_node.c.erb"
2185
2185
  argv[4] = rb_ary_pop(value_stack);
2186
2186
 
2187
- // operator
2187
+ // binary_operator
2188
2188
  #line 198 "api_node.c.erb"
2189
- assert(cast->operator != 0);
2190
- argv[5] = RARRAY_AREF(constants, cast->operator - 1);
2189
+ assert(cast->binary_operator != 0);
2190
+ argv[5] = RARRAY_AREF(constants, cast->binary_operator - 1);
2191
2191
 
2192
2192
  // location
2193
2193
  argv[6] = pm_location_new(parser, node->location.start, node->location.end);
@@ -2293,18 +2293,18 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
2293
2293
  #line 186 "api_node.c.erb"
2294
2294
  argv[1] = rb_ary_pop(value_stack);
2295
2295
 
2296
- // operator_loc
2296
+ // binary_operator_loc
2297
2297
  #line 211 "api_node.c.erb"
2298
- argv[2] = pm_location_new(parser, cast->operator_loc.start, cast->operator_loc.end);
2298
+ argv[2] = pm_location_new(parser, cast->binary_operator_loc.start, cast->binary_operator_loc.end);
2299
2299
 
2300
2300
  // value
2301
2301
  #line 186 "api_node.c.erb"
2302
2302
  argv[3] = rb_ary_pop(value_stack);
2303
2303
 
2304
- // operator
2304
+ // binary_operator
2305
2305
  #line 198 "api_node.c.erb"
2306
- assert(cast->operator != 0);
2307
- argv[4] = RARRAY_AREF(constants, cast->operator - 1);
2306
+ assert(cast->binary_operator != 0);
2307
+ argv[4] = RARRAY_AREF(constants, cast->binary_operator - 1);
2308
2308
 
2309
2309
  // location
2310
2310
  argv[5] = pm_location_new(parser, node->location.start, node->location.end);
@@ -2894,18 +2894,18 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
2894
2894
  #line 211 "api_node.c.erb"
2895
2895
  argv[2] = pm_location_new(parser, cast->name_loc.start, cast->name_loc.end);
2896
2896
 
2897
- // operator_loc
2897
+ // binary_operator_loc
2898
2898
  #line 211 "api_node.c.erb"
2899
- argv[3] = pm_location_new(parser, cast->operator_loc.start, cast->operator_loc.end);
2899
+ argv[3] = pm_location_new(parser, cast->binary_operator_loc.start, cast->binary_operator_loc.end);
2900
2900
 
2901
2901
  // value
2902
2902
  #line 186 "api_node.c.erb"
2903
2903
  argv[4] = rb_ary_pop(value_stack);
2904
2904
 
2905
- // operator
2905
+ // binary_operator
2906
2906
  #line 198 "api_node.c.erb"
2907
- assert(cast->operator != 0);
2908
- argv[5] = RARRAY_AREF(constants, cast->operator - 1);
2907
+ assert(cast->binary_operator != 0);
2908
+ argv[5] = RARRAY_AREF(constants, cast->binary_operator - 1);
2909
2909
 
2910
2910
  // location
2911
2911
  argv[6] = pm_location_new(parser, node->location.start, node->location.end);
@@ -3280,14 +3280,14 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
3280
3280
  #line 186 "api_node.c.erb"
3281
3281
  argv[7] = rb_ary_pop(value_stack);
3282
3282
 
3283
- // operator
3283
+ // binary_operator
3284
3284
  #line 198 "api_node.c.erb"
3285
- assert(cast->operator != 0);
3286
- argv[8] = RARRAY_AREF(constants, cast->operator - 1);
3285
+ assert(cast->binary_operator != 0);
3286
+ argv[8] = RARRAY_AREF(constants, cast->binary_operator - 1);
3287
3287
 
3288
- // operator_loc
3288
+ // binary_operator_loc
3289
3289
  #line 211 "api_node.c.erb"
3290
- argv[9] = pm_location_new(parser, cast->operator_loc.start, cast->operator_loc.end);
3290
+ argv[9] = pm_location_new(parser, cast->binary_operator_loc.start, cast->binary_operator_loc.end);
3291
3291
 
3292
3292
  // value
3293
3293
  #line 186 "api_node.c.erb"
@@ -3435,18 +3435,18 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
3435
3435
  #line 211 "api_node.c.erb"
3436
3436
  argv[2] = pm_location_new(parser, cast->name_loc.start, cast->name_loc.end);
3437
3437
 
3438
- // operator_loc
3438
+ // binary_operator_loc
3439
3439
  #line 211 "api_node.c.erb"
3440
- argv[3] = pm_location_new(parser, cast->operator_loc.start, cast->operator_loc.end);
3440
+ argv[3] = pm_location_new(parser, cast->binary_operator_loc.start, cast->binary_operator_loc.end);
3441
3441
 
3442
3442
  // value
3443
3443
  #line 186 "api_node.c.erb"
3444
3444
  argv[4] = rb_ary_pop(value_stack);
3445
3445
 
3446
- // operator
3446
+ // binary_operator
3447
3447
  #line 198 "api_node.c.erb"
3448
- assert(cast->operator != 0);
3449
- argv[5] = RARRAY_AREF(constants, cast->operator - 1);
3448
+ assert(cast->binary_operator != 0);
3449
+ argv[5] = RARRAY_AREF(constants, cast->binary_operator - 1);
3450
3450
 
3451
3451
  // location
3452
3452
  argv[6] = pm_location_new(parser, node->location.start, node->location.end);
@@ -3889,9 +3889,9 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
3889
3889
  #line 211 "api_node.c.erb"
3890
3890
  argv[1] = pm_location_new(parser, cast->name_loc.start, cast->name_loc.end);
3891
3891
 
3892
- // operator_loc
3892
+ // binary_operator_loc
3893
3893
  #line 211 "api_node.c.erb"
3894
- argv[2] = pm_location_new(parser, cast->operator_loc.start, cast->operator_loc.end);
3894
+ argv[2] = pm_location_new(parser, cast->binary_operator_loc.start, cast->binary_operator_loc.end);
3895
3895
 
3896
3896
  // value
3897
3897
  #line 186 "api_node.c.erb"
@@ -3902,10 +3902,10 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
3902
3902
  assert(cast->name != 0);
3903
3903
  argv[4] = RARRAY_AREF(constants, cast->name - 1);
3904
3904
 
3905
- // operator
3905
+ // binary_operator
3906
3906
  #line 198 "api_node.c.erb"
3907
- assert(cast->operator != 0);
3908
- argv[5] = RARRAY_AREF(constants, cast->operator - 1);
3907
+ assert(cast->binary_operator != 0);
3908
+ argv[5] = RARRAY_AREF(constants, cast->binary_operator - 1);
3909
3909
 
3910
3910
  // depth
3911
3911
  #line 220 "api_node.c.erb"
data/ext/prism/extconf.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "rbconfig"
4
+
3
5
  if ARGV.delete("--help")
4
6
  print(<<~TEXT)
5
7
  USAGE: ruby #{$PROGRAM_NAME} [options]
@@ -40,26 +42,6 @@ def generate_templates
40
42
  end
41
43
  end
42
44
 
43
- # We're going to need to run `make` using prism's `Makefile`. We want to match
44
- # up as much of the configuration to the configuration that built the current
45
- # version of Ruby as possible.
46
- require "rbconfig"
47
- env = RbConfig::CONFIG.slice("SOEXT", "CPPFLAGS", "CFLAGS", "CC", "AR", "ARFLAGS", "MAKEDIRS", "RMALL")
48
-
49
- # It's possible that the Ruby that is being run wasn't actually compiled on this
50
- # machine, in which case the configuration might be incorrect. In this case
51
- # we'll need to do some additional checks and potentially fall back to defaults.
52
- if env.key?("CC") && !File.exist?(env["CC"])
53
- env.delete("CC")
54
- env.delete("CFLAGS")
55
- env.delete("CPPFLAGS")
56
- end
57
-
58
- if env.key?("AR") && !File.exist?(env["AR"])
59
- env.delete("AR")
60
- env.delete("ARFLAGS")
61
- end
62
-
63
45
  # Runs `make` in the root directory of the project. Note that this is the
64
46
  # `Makefile` for the overall project, not the `Makefile` that is being generated
65
47
  # by this script.`
@@ -77,15 +59,37 @@ end
77
59
 
78
60
  # On non-CRuby we only need the shared library since we'll interface with it
79
61
  # through FFI, so we'll build only that and not the C extension. We also avoid
80
- # `require "mkmf"` as that prepends the LLVM toolchain to PATH on TruffleRuby,
81
- # but we want to use the native toolchain here since libprism is run natively.
62
+ # `require "mkmf"` as that prepends the GraalVM LLVM toolchain to PATH on TruffleRuby < 24.0,
63
+ # but we want to use the system toolchain here since libprism is run natively.
82
64
  if RUBY_ENGINE != "ruby"
83
65
  generate_templates
84
- make(env, "build/libprism.#{RbConfig::CONFIG["SOEXT"]}")
66
+ soext = RbConfig::CONFIG["SOEXT"]
67
+ # Pass SOEXT to avoid an extra subprocess just to query that
68
+ make({ "SOEXT" => soext }, "build/libprism.#{soext}")
85
69
  File.write("Makefile", "all install clean:\n\t@#{RbConfig::CONFIG["NULLCMD"]}\n")
86
70
  return
87
71
  end
88
72
 
73
+ # We're going to need to run `make` using prism's `Makefile`.
74
+ # We want to use the same toolchain (compiler, flags, etc) to compile libprism.a and
75
+ # the C extension since they will be linked together.
76
+ # The C extension uses RbConfig, which contains values from the toolchain that built the running Ruby.
77
+ env = RbConfig::CONFIG.slice("SOEXT", "CPPFLAGS", "CFLAGS", "CC", "AR", "ARFLAGS", "MAKEDIRS", "RMALL")
78
+
79
+ # It's possible that the Ruby that is being run wasn't actually compiled on this
80
+ # machine, in which case parts of RbConfig might be incorrect. In this case
81
+ # we'll need to do some additional checks and potentially fall back to defaults.
82
+ if env.key?("CC") && !File.exist?(env["CC"])
83
+ env.delete("CC")
84
+ env.delete("CFLAGS")
85
+ env.delete("CPPFLAGS")
86
+ end
87
+
88
+ if env.key?("AR") && !File.exist?(env["AR"])
89
+ env.delete("AR")
90
+ env.delete("ARFLAGS")
91
+ end
92
+
89
93
  require "mkmf"
90
94
 
91
95
  # First, ensure that we can find the header for the prism library.
@@ -1,7 +1,7 @@
1
1
  #ifndef PRISM_EXT_NODE_H
2
2
  #define PRISM_EXT_NODE_H
3
3
 
4
- #define EXPECTED_PRISM_VERSION "0.28.0"
4
+ #define EXPECTED_PRISM_VERSION "0.29.0"
5
5
 
6
6
  #include <ruby.h>
7
7
  #include <ruby/encoding.h>
data/include/prism/ast.h CHANGED
@@ -1818,14 +1818,14 @@ typedef struct pm_call_operator_write_node {
1818
1818
  pm_constant_id_t write_name;
1819
1819
 
1820
1820
  /**
1821
- * CallOperatorWriteNode#operator
1821
+ * CallOperatorWriteNode#binary_operator
1822
1822
  */
1823
- pm_constant_id_t operator;
1823
+ pm_constant_id_t binary_operator;
1824
1824
 
1825
1825
  /**
1826
- * CallOperatorWriteNode#operator_loc
1826
+ * CallOperatorWriteNode#binary_operator_loc
1827
1827
  */
1828
- pm_location_t operator_loc;
1828
+ pm_location_t binary_operator_loc;
1829
1829
 
1830
1830
  /**
1831
1831
  * CallOperatorWriteNode#value
@@ -2129,9 +2129,9 @@ typedef struct pm_class_variable_operator_write_node {
2129
2129
  pm_location_t name_loc;
2130
2130
 
2131
2131
  /**
2132
- * ClassVariableOperatorWriteNode#operator_loc
2132
+ * ClassVariableOperatorWriteNode#binary_operator_loc
2133
2133
  */
2134
- pm_location_t operator_loc;
2134
+ pm_location_t binary_operator_loc;
2135
2135
 
2136
2136
  /**
2137
2137
  * ClassVariableOperatorWriteNode#value
@@ -2139,9 +2139,9 @@ typedef struct pm_class_variable_operator_write_node {
2139
2139
  struct pm_node *value;
2140
2140
 
2141
2141
  /**
2142
- * ClassVariableOperatorWriteNode#operator
2142
+ * ClassVariableOperatorWriteNode#binary_operator
2143
2143
  */
2144
- pm_constant_id_t operator;
2144
+ pm_constant_id_t binary_operator;
2145
2145
  } pm_class_variable_operator_write_node_t;
2146
2146
 
2147
2147
  /**
@@ -2326,9 +2326,9 @@ typedef struct pm_constant_operator_write_node {
2326
2326
  pm_location_t name_loc;
2327
2327
 
2328
2328
  /**
2329
- * ConstantOperatorWriteNode#operator_loc
2329
+ * ConstantOperatorWriteNode#binary_operator_loc
2330
2330
  */
2331
- pm_location_t operator_loc;
2331
+ pm_location_t binary_operator_loc;
2332
2332
 
2333
2333
  /**
2334
2334
  * ConstantOperatorWriteNode#value
@@ -2336,9 +2336,9 @@ typedef struct pm_constant_operator_write_node {
2336
2336
  struct pm_node *value;
2337
2337
 
2338
2338
  /**
2339
- * ConstantOperatorWriteNode#operator
2339
+ * ConstantOperatorWriteNode#binary_operator
2340
2340
  */
2341
- pm_constant_id_t operator;
2341
+ pm_constant_id_t binary_operator;
2342
2342
  } pm_constant_operator_write_node_t;
2343
2343
 
2344
2344
  /**
@@ -2478,9 +2478,9 @@ typedef struct pm_constant_path_operator_write_node {
2478
2478
  struct pm_constant_path_node *target;
2479
2479
 
2480
2480
  /**
2481
- * ConstantPathOperatorWriteNode#operator_loc
2481
+ * ConstantPathOperatorWriteNode#binary_operator_loc
2482
2482
  */
2483
- pm_location_t operator_loc;
2483
+ pm_location_t binary_operator_loc;
2484
2484
 
2485
2485
  /**
2486
2486
  * ConstantPathOperatorWriteNode#value
@@ -2488,9 +2488,9 @@ typedef struct pm_constant_path_operator_write_node {
2488
2488
  struct pm_node *value;
2489
2489
 
2490
2490
  /**
2491
- * ConstantPathOperatorWriteNode#operator
2491
+ * ConstantPathOperatorWriteNode#binary_operator
2492
2492
  */
2493
- pm_constant_id_t operator;
2493
+ pm_constant_id_t binary_operator;
2494
2494
  } pm_constant_path_operator_write_node_t;
2495
2495
 
2496
2496
  /**
@@ -3144,9 +3144,9 @@ typedef struct pm_global_variable_operator_write_node {
3144
3144
  pm_location_t name_loc;
3145
3145
 
3146
3146
  /**
3147
- * GlobalVariableOperatorWriteNode#operator_loc
3147
+ * GlobalVariableOperatorWriteNode#binary_operator_loc
3148
3148
  */
3149
- pm_location_t operator_loc;
3149
+ pm_location_t binary_operator_loc;
3150
3150
 
3151
3151
  /**
3152
3152
  * GlobalVariableOperatorWriteNode#value
@@ -3154,9 +3154,9 @@ typedef struct pm_global_variable_operator_write_node {
3154
3154
  struct pm_node *value;
3155
3155
 
3156
3156
  /**
3157
- * GlobalVariableOperatorWriteNode#operator
3157
+ * GlobalVariableOperatorWriteNode#binary_operator
3158
3158
  */
3159
- pm_constant_id_t operator;
3159
+ pm_constant_id_t binary_operator;
3160
3160
  } pm_global_variable_operator_write_node_t;
3161
3161
 
3162
3162
  /**
@@ -3651,14 +3651,14 @@ typedef struct pm_index_operator_write_node {
3651
3651
  struct pm_node *block;
3652
3652
 
3653
3653
  /**
3654
- * IndexOperatorWriteNode#operator
3654
+ * IndexOperatorWriteNode#binary_operator
3655
3655
  */
3656
- pm_constant_id_t operator;
3656
+ pm_constant_id_t binary_operator;
3657
3657
 
3658
3658
  /**
3659
- * IndexOperatorWriteNode#operator_loc
3659
+ * IndexOperatorWriteNode#binary_operator_loc
3660
3660
  */
3661
- pm_location_t operator_loc;
3661
+ pm_location_t binary_operator_loc;
3662
3662
 
3663
3663
  /**
3664
3664
  * IndexOperatorWriteNode#value
@@ -3819,9 +3819,9 @@ typedef struct pm_instance_variable_operator_write_node {
3819
3819
  pm_location_t name_loc;
3820
3820
 
3821
3821
  /**
3822
- * InstanceVariableOperatorWriteNode#operator_loc
3822
+ * InstanceVariableOperatorWriteNode#binary_operator_loc
3823
3823
  */
3824
- pm_location_t operator_loc;
3824
+ pm_location_t binary_operator_loc;
3825
3825
 
3826
3826
  /**
3827
3827
  * InstanceVariableOperatorWriteNode#value
@@ -3829,9 +3829,9 @@ typedef struct pm_instance_variable_operator_write_node {
3829
3829
  struct pm_node *value;
3830
3830
 
3831
3831
  /**
3832
- * InstanceVariableOperatorWriteNode#operator
3832
+ * InstanceVariableOperatorWriteNode#binary_operator
3833
3833
  */
3834
- pm_constant_id_t operator;
3834
+ pm_constant_id_t binary_operator;
3835
3835
  } pm_instance_variable_operator_write_node_t;
3836
3836
 
3837
3837
  /**
@@ -4304,9 +4304,9 @@ typedef struct pm_local_variable_operator_write_node {
4304
4304
  pm_location_t name_loc;
4305
4305
 
4306
4306
  /**
4307
- * LocalVariableOperatorWriteNode#operator_loc
4307
+ * LocalVariableOperatorWriteNode#binary_operator_loc
4308
4308
  */
4309
- pm_location_t operator_loc;
4309
+ pm_location_t binary_operator_loc;
4310
4310
 
4311
4311
  /**
4312
4312
  * LocalVariableOperatorWriteNode#value
@@ -4319,9 +4319,9 @@ typedef struct pm_local_variable_operator_write_node {
4319
4319
  pm_constant_id_t name;
4320
4320
 
4321
4321
  /**
4322
- * LocalVariableOperatorWriteNode#operator
4322
+ * LocalVariableOperatorWriteNode#binary_operator
4323
4323
  */
4324
- pm_constant_id_t operator;
4324
+ pm_constant_id_t binary_operator;
4325
4325
 
4326
4326
  /**
4327
4327
  * LocalVariableOperatorWriteNode#depth