Commit graph

18546 commits

Author SHA1 Message Date
Nobuyoshi Nakada
f5c3cda7d6 Do not change hash type in Hash#assoc 2023-11-21 15:15:23 +09:00
Yusuke Endoh
1cf2fa3af5 Raise an exception when Hash#compare_by_identity during its iteration 2023-11-21 15:15:23 +09:00
TSUYUSATO Kitsune
a861c74813 Add a test 2023-11-21 14:07:47 +09:00
Kouhei Yanagita
04eb40b633 [Bug #11183] Fix rb_complex_pow for special angles
Add a special treatment for when the argument of self is an
integral multiple of 45 degrees.

  1i ** (10 ** 100)         #=> 1+0i
  1i ** (10 ** 100 + 1)     #=> 0+1i
  (1+1i) ** (10 ** 100)     # warning: in a**b, b may be too big
                            #=> (Infinity+0.0i)
  (1+1i) ** (10 ** 100 + 1) # warning: in a**b, b may be too big
                            #=> (Infinity+Infinity*i)
2023-11-21 14:06:26 +09:00
Hiroya Fujinami
b6b31f673d [ruby/prism] Check a token after targets more strictly
(https://github.com/ruby/prism/pull/1878)

Fix https://github.com/ruby/prism/pull/1832

060bcc81a8
2023-11-21 02:45:12 +00:00
Kevin Newton
5299b4a362 [ruby/prism] Build the ability to format errors
(https://github.com/ruby/prism/pull/1796)

Previously, we only supported error messages that were constant
strings. This works for the most part, but there are some times
where we want to include some part of the source in the error
message to make it better.

For example, instead of "Token is reserved" it's better to write
"_1 is reserved".

To do this, we now support allocating error messages at runtime
that are built around format strings.

7e6aa17deb
2023-11-21 02:43:18 +00:00
Kevin Newton
9fa524dd41 [ruby/prism] Split up CaseNode and CaseMatchNode
(https://github.com/ruby/prism/pull/1801)

4c1391ea56
2023-11-21 02:38:07 +00:00
Ryan Garver
e16ff17374 Rename the big5-hkscs stuff to something more generic and add UAO sharing common code.
Merge the Big5 extensions into pm_big5.c
2023-11-20 21:18:31 -05:00
dependabot[bot]
a4003bb8dc [rubygems/rubygems] Bump rb-sys
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.82 to 0.9.83.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.82...v0.9.83)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

9eb6220c6c
2023-11-21 01:45:54 +00:00
dependabot[bot]
7960db04b1 [rubygems/rubygems] Bump rb-sys
Bumps [rb-sys](https://github.com/oxidize-rb/rb-sys) from 0.9.82 to 0.9.83.
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.82...v0.9.83)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

41670ad4e2
2023-11-21 00:58:08 +00:00
ima1zumi
7164715666 [ruby/irb] Enable Setting Completer Type through IRB_COMPLETOR
(https://github.com/ruby/irb/pull/771)

I propose introducing the capability to set the IRB completion kinds via an environment variable, specifically `IRB_COMPLETOR=type`.
This feature aims to enhance the Rails console experience by allowing Rails users to specify their preferred completion more conveniently.

Currently, when using the Rails console, there's no straightforward way to globally set the type completion across a Rails application repository.
It's possible to configure this setting by placing a `.irbrc` file at the project root. However, using a .irbrc file is not ideal as it allows for broad configurations and can potentially affect the production environment.
My suggestion focuses on allowing users to set the completion to 'type' in a minimal.

This enhancement would be particularly beneficial for teams writing RBS in their Rails applications.
This type completer, integrated with RBS, would enhance completion accuracy, improving the Rails console experience.

032f6da25f
2023-11-21 00:04:41 +00:00
Haldun Bayhantopcu
36afc11ece [ruby/prism] Fix locations derived from arguments.
(https://github.com/ruby/prism/pull/1897)

00b76ef254
2023-11-20 23:03:23 +00:00
Kevin Newton
e269096d15 [ruby/prism] Replace match write locals with match write targets
eec1862967
2023-11-20 18:00:44 -05:00
Peter Zhu
f376163194 Fix crash when evacuating generic ivar
When transitioning generic instance variable objects to too complex, we
set the shape first before performing inserting the new gen_ivtbl. The
st_insert for the new gen_ivtbl could allocate and cause a GC. If that
happens, then it will crash because the object will have a too complex
shape but not yet be backed by a st_table.

This commit changes the order so that the insert happens first before
the new shape is set.

The following script reproduces the issue:

```
o = []
o.instance_variable_set(:@a, 1)

i = 0
o = Object.new
while RubyVM::Shape.shapes_available > 0
  o.instance_variable_set(:"@i#{i}", 1)
  i += 1
end

ary = 1_000.times.map { [] }

GC.stress = true
ary.each do |o|
  o.instance_variable_set(:@a, 1)
  o.instance_variable_set(:@b, 1)
end
```
2023-11-20 16:57:24 -05:00
Jemma Issroff
103bbd21f8 [PRISM] Updated LocalVariableTargetNodes too 2023-11-20 13:48:46 -08:00
Jemma Issroff
b913626bea [PRISM] Fix LocalVariableWriteNodes within blocks
Prior to this commit, we weren't recursing up scopes to look for
the local definition. With this commit, we do so, fixing local writes
within blocks
2023-11-20 13:48:46 -08:00
eileencodes
2796e4ece2 [PRISM] Implement once node for interpolated regex
This PR implements the once node on interpolated regexes.

There is a bug in Prism where the interpolated regex with the once flag
only works when there is not a local variable so the test uses a "1".
We'll need to fix that.
2023-11-20 12:42:05 -08:00
Jemma Issroff
c5d5929443 [PRISM] Don't pop args to YieldNode 2023-11-20 12:12:34 -08:00
Lynne Ashminov
307a5cb20b [ruby/prism] adds encodings for ibm869
(https://github.com/ruby/prism/pull/1886)

41462400b7
2023-11-20 20:06:14 +00:00
Maple Ong
9fbdb26f06 [ruby/prism] Add and test ibm863 encoding
(https://github.com/ruby/prism/pull/1853)

* Add and test ibm863

* Remove dup encoding and add alias

* Update test/prism/encoding_test.rb

Co-authored-by: Kevin Newton <kddnewton@gmail.com>

* Readd bitfield table lol

---------

4cd756d7ff

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2023-11-20 20:06:00 +00:00
Kevin Newton
5b0256e3c4 [ruby/prism] Disallow defining a numbered parameter method
(https://github.com/ruby/prism/pull/1797)

c13165e6aa
2023-11-20 16:12:50 +00:00
David Wessman
f9fb05f9d0 [ruby/prism] feat: Adds macCroatian encoding
(https://github.com/ruby/prism/pull/1880)

* feat: Adds macCroatian encoding

- Based on:
https://en.wikipedia.org/wiki/Mac_OS_Croatian_encoding
https://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/CROATIAN.TXT

Co-authored-by: Josefine Rost <nijrost@gmail.com>

* Use output from bin/encodings and adds to docs/encoding.md

---------

019a82d8f3

Co-authored-by: Josefine Rost <nijrost@gmail.com>
2023-11-20 16:07:19 +00:00
Kevin Newton
f2ed7eaba0 [ruby/prism] Add character APIs for locations
(https://github.com/ruby/prism/pull/1809)

d493ccd093
2023-11-20 16:07:06 +00:00
Hiroya Fujinami
adee7dab3e [ruby/prism] Correctly parse the resuce modifier in the rhs of the
assignments
(https://github.com/ruby/prism/pull/1879)

Fix https://github.com/ruby/prism/pull/1541

9fb276e1f4
2023-11-20 15:58:19 +00:00
Hiroya Fujinami
caa9ae7804 [ruby/prism] Fix parsing ... in arguments
(https://github.com/ruby/prism/pull/1882)

* Fix parsing `...` in arguments

Fix https://github.com/ruby/prism/pull/1830
Fix https://github.com/ruby/prism/pull/1831

* Rename the constant name to PM_ERR_ARGUMENT_FORWARDING_UNBOUND

https://github.com/ruby/prism/pull/1882#discussion_r1398461156

519653aec2
2023-11-20 15:52:44 +00:00
Peter Zhu
83da4a7e62 Fix crash when iterating over generic ivars 2023-11-20 10:13:18 -05:00
Derek Moore
701b0650de [ruby/prism] feat: add encoding for IBM865
(https://github.com/ruby/prism/pull/1884)

* feat: add encoding for IBM865

* style: fix incorrect autoformat

14c6ae0182
2023-11-20 02:02:55 +00:00
Hiroya Fujinami
8b4b0b7177 [ruby/prism] Don't add an invalid identifier capture to locals
(https://github.com/ruby/prism/pull/1836)

* Don't add an invalid identifier capture to locals

Fix https://github.com/ruby/prism/pull/1815

* Delay creating a MatchWriteNode

https://github.com/ruby/prism/pull/1836#discussion_r1393716600

635f595a36
2023-11-19 02:05:21 +00:00
Syed Faraaz Ahmad
5fea1d08bd [ruby/prism] feat: add encoding for ibm866
(https://github.com/ruby/prism/pull/1864)

Add encoding for ibm866

---------

1a96cc71f7

Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2023-11-19 01:05:41 +00:00
Orhan Toy
5d2d0962cc [ruby/prism] Add GB1988 encoding
78d3fa7172
2023-11-19 01:05:11 +00:00
Orhan Toy
71a30b7596 [ruby/prism] Add macCyrillic encoding
220b40921a
2023-11-19 01:03:19 +00:00
Ryan Garver
cd4316a51f [ruby/prism] Big5 HKSCS encoding
3ca9823eb4
2023-11-18 13:52:17 -05:00
Mike Dalton
bbf14bbba6 [ruby/prism] Add IBM864 encoding
Fixes https://github.com/ruby/prism/pull/1868
Related #1843

abc136dfc9
2023-11-18 18:47:15 +00:00
Thomas Marshall
a6f9e6add2 [ruby/prism] Add macCentEuro encoding
ff95edbd99
2023-11-18 18:41:03 +00:00
tomoya ishida
631b500dd5 [ruby/irb] Fix irb crash on {}. completion
(https://github.com/ruby/irb/pull/764)

07e4d540cc
2023-11-18 17:49:06 +00:00
Jeremy Evans
ae48d4ad2e Ensure keyword splat method argument is hash
Commit e87d088291 introduced a
regression where the keyword splat object passed by the caller
would be directly used by callee as keyword splat parameters,
if it implemented #to_hash.  The return value of #to_hash would be
ignored in this case.
2023-11-18 09:44:42 -08:00
Peter Zhu
3dd77bc056 Fix corruption when out of shape during ivar remove
Reproduction script:

```
o = Object.new
10.times { |i| o.instance_variable_set(:"@a#{i}", i) }

i = 0
a = Object.new
while RubyVM::Shape.shapes_available > 2
  a.instance_variable_set(:"@i#{i}", 1)
  i += 1
end

o.remove_instance_variable(:@a0)

puts o.instance_variable_get(:@a1)
```

Before this patch, it would incorrectly output `2` and now it correctly
outputs `1`.
2023-11-17 13:08:43 -08:00
Peter Cai
585fdfe1f5 [ruby/prism] add Windows-874 encoding
0670dd3b9a
2023-11-17 20:06:48 +00:00
Kevin Newton
229f6e5bb4 [ruby/prism] Update spacing in encoding_test.rb
56508c2201
2023-11-17 20:06:28 +00:00
Haldun Bayhantopcu
50b7b927a3 [ruby/prism] Add macThai
f654058f50
2023-11-17 20:06:27 +00:00
Haldun Bayhantopcu
0a081a33eb [ruby/prism] Add macRoman
42b20ee399
2023-11-17 20:06:16 +00:00
Haldun Bayhantopcu
e5d6b4099e [ruby/prism] Do not allow trailing commas in calls without parenthesis
f1d56da58f
2023-11-17 15:48:57 +00:00
Kevin Newton
db4303f953 [ruby/prism] Never test locale encoding
f0f057b055
2023-11-17 15:28:08 +00:00
Kevin Newton
c2f2090da6 [ruby/prism] Do not test locale encoding on windows
8f40536431
2023-11-17 14:50:31 +00:00
Haldun Bayhantopcu
4a26a65e42 [ruby/prism] Add macTurkish
2232d4b6a0
2023-11-17 14:32:40 +00:00
Yusuke Endoh
498b086c37 Skip test_ForwardingArgumentsNode
due to a failure on a CI

http://ci.rvm.jp/results/trunk-iseq_binary@ruby-sp2-docker/4779277
```
expected:
== disasm: #<ISeq:prism_test_forwarding_arguments_node1@<compiled>:2 (2,8)-(4,11)>
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: 1])
[ 1] "..."@0
0000 putself                                                          (   3)
0001 getlocal_WC_0                          ?@-2
0003 splatarray                             false
0005 getblockparamproxy                     ?@-1, 0
0008 send                                   <calldata!mid:prism_test_forwarding_arguments_node, argc:1, ARGS_SPLAT|ARGS_BLOCKARG|FCALL>, nil
0011 leave                                                            (   2)
actual:
== disasm: #<ISeq:prism_test_forwarding_arguments_node1@<compiled>:2 (2,8)-(4,11)>
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: 1])
[ 1] "..."@0
0000 putself                                                          (   3)
0001 getlocal_WC_0                          ?@-2
0003 splatarray                             false
0005 getblockparamproxy                     "!"@-1, 0
0008 send                                   <calldata!mid:prism_test_forwarding_arguments_node, argc:1, ARGS_SPLAT|ARGS_BLOCKARG|FCALL>, nil
0011 leave                                                            (   2)
/tmp/ruby/src/trunk-iseq_binary/tool/lib/iseq_loader_checker.rb:36:in `exit': exit (SystemExit)
```
2023-11-17 11:01:55 +09:00
Kevin Newton
3bc41f4f0b [ruby/prism] Add macGreek encoding
c36d3fc647
2023-11-16 18:00:08 +00:00
Kevin Newton
ce85355931 [ruby/prism] Only run encoding tests on CRuby
a63acc0629
2023-11-16 17:39:40 +00:00
Kevin Newton
4b2915f0b9 [ruby/prism] Add macRomania encoding
bb73801cf4
2023-11-16 17:39:40 +00:00
Kevin Newton
b753e16945 [ruby/prism] IBM862 encoding
151698bf86
2023-11-16 17:39:38 +00:00