Skip to content

Commit ce5c3f0

Browse files
committed
[GR-19220] Add support for Ruby 3.1's Hash shorthand/punning syntax (#2694)
PullRequest: truffleruby/3441
2 parents ca0c55e + 398c8c9 commit ce5c3f0

File tree

8 files changed

+1681
-1633
lines changed

8 files changed

+1681
-1633
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ New features:
44

55
* Foreign strings now have all methods of Ruby `String`. They are treated as `#frozen?` UTF-8 Ruby Strings.
66
* Add `Java.add_to_classpath` method to add jar paths at runtime (#2693, @bjfish).
7+
* Add support for Ruby 3.1's Hash shorthand/punning syntax (@nirvdrum).
78

89
Bug fixes:
910

spec/tags/language/hash_tags.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
fails:The ** operator makes a caller-side copy when calling a method taking a positional Hash
22
fails:Hash literal checks duplicated keys on initialization
3+
fails:Hash literal checks duplicated float keys on initialization

spec/truffleruby.mspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class MSpecScript
103103

104104
# Use spec/ruby/core/nil/nil_spec.rb as a dummy file to avoid being empty
105105
set :next, %w[
106+
spec/ruby/language/hash_spec.rb
106107
spec/ruby/core/nil/nil_spec.rb
107108
spec/ruby/core/gc/measure_total_time_spec.rb
108109
spec/ruby/core/gc/total_time_spec.rb

src/main/java/org/truffleruby/parser/parser/RubyParser.java

Lines changed: 126 additions & 120 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/org/truffleruby/parser/parser/RubyParser.y

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,6 +2735,11 @@ assoc : arg_value tASSOC arg_value {
27352735
ParseNode label = support.asSymbol(support.getPosition($2), $1);
27362736
$$ = support.createKeyValue(label, $2);
27372737
}
2738+
| tLABEL {
2739+
ParseNode val = support.declareIdentifier($1);
2740+
ParseNode label = support.asSymbol(support.getPosition(null), $1);
2741+
$$ = support.createKeyValue(label, val);
2742+
}
27382743
| tSTRING_BEG string_contents tLABEL_END arg_value {
27392744
if ($2 instanceof StrParseNode) {
27402745
DStrParseNode dnode = new DStrParseNode(support.getPosition($2), lexer.getEncoding());

src/main/java/org/truffleruby/parser/parser/YyTables.java

Lines changed: 1545 additions & 1513 deletions
Large diffs are not rendered by default.

test/mri/excludes/OpenSSL/TestOCSP.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exclude :test_basic_response_response_operations, "transient"

test/mri/excludes/TestThread.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@
2222
exclude :test_ignore_deadlock, "needs investigation"
2323
exclude :test_switch_while_busy_loop, "transient"
2424
exclude :test_handle_interrupt_and_p, "transient"
25+
exclude :test_thread_value_in_trap, "transient"

0 commit comments

Comments
 (0)