summaryrefslogtreecommitdiff
path: root/test/ruby
AgeCommit message (Collapse)Author
2024-01-17[Prism] Implement defined? for PM_INDEX_OPERATOR_WRITE_NODEeileencodes
Ruby code: ```ruby defined?([0][0] += 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_INDEX_AND_WRITE_NODEeileencodes
Ruby code: ```ruby defined?([0][0] &&= 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CONSTANT_PATH_WRITE_NODEeileencodes
Ruby code: ```ruby defined?(Prism::CPWN = 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CONSTANT_PATH_OR_WRITE_NODEeileencodes
Ruby code: ```ruby defined?(Prism::CPOrWN ||= 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CONSTANT_PATH_OPERATOR_WRITE_NODEeileencodes
Ruby code: ```ruby defined?(Prism::CPOWN += 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CONSTANT_PATH_AND_WRITE_NODEeileencodes
Ruby code: ```ruby defined?(Prism::CPAWN &&= 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CALL_OR_WRITE_NODEeileencodes
Ruby code: ```ruby defined?(PrismTestSubclass.test_call_or_write_node ||= 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CALL_OPERATOR_WRITE_NODEeileencodes
Ruby code: ```ruby defined?(PrismTestSubclass.test_call_operator_write_node += 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_CALL_AND_WRITE_NODEeileencodes
Ruby code: ```ruby defined?(PrismTestSubclass.test_call_and_write_node &&= 1) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,58)> 0000 putobject "assignment" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,58)> 0000 putobject "assignment" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[PRISM] Fix crash in compile_prismPeter Zhu
If the argument is not a file or a string, it assumes it's a string which will crash because RSTRING_PTR and RSTRING_LEN assumes it's a string.
2024-01-17[PRISM] Fix fallthrough for PM_ENSURE_NODEPeter Zhu
This caused it to fall into PM_ELSE_NODE which caused ensure nodes to be compiled twice. Fixes ruby/prism#2176.
2024-01-17[Prism] Fix more method call argumnentseileencodes
In #2087 it was noted that there was a bug in the number of arguments in `SplatNode` and `KeywordHashNode`. I looked into this with Aaron before the linked PR was merged and we found a bunch of cases that weren't working quite right. This PR aims to fix some of those cases, but there may be more. A splat argument followed by a positional argument will concat the array until the end or unless the argument is a kwarg or splat kwarg. For example ``` foo(a, *b, c, *d, e) ``` Will have an `argc` of 2, because `b`, `c`, `d`, and `e` will be concatenated together. ``` foo(a, *b, c, *d, **e) ``` Will have an `argc` of 3, because `b`, `c`, and `d` will be concatenated together and `e` is a separate argument.
2024-01-17YJIT: Support empty splat and some block_arg calls to ivar getters (#9567)Alan Wu
These seem odd at first glance, but they're used with `...` calls with `Module#delegate` from Active Support. These account for ~3% of fallback reasons in the `lobsters` benchmark.
2024-01-17[Prism] Fix return testeileencodes
This test didn't work as is because it causes a SyntaxError. Instead we need to put the `defined?(return)` into a method and call that. I double checked that on the `master` branch this returns an Unsupported node error.
2024-01-17[Prism] Implement defined? for PM_BEGIN_NODEeileencodes
Ruby code: ```ruby defined?(begin; 1; end) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,23)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,23)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_RETRY_NODEeileencodes
Ruby code: ```ruby defined?(retry) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,15)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,15)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_RETURN_NODEeileencodes
Ruby code: ```ruby defined?(return) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,16)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,16)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_REDO_NODEeileencodes
Ruby code: ```ruby defined?(redo) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,14)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,14)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_INTERPOLATED_X_STRING_NODEeileencodes
Ruby code: ```ruby defined?(`echo #{1}`) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,21)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,21)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_INTERPOLATED_SYMBOL_NODEeileencodes
Ruby code: ```ruby defined?(:"1 #{1 + 2} 1") ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,25)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,25)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_DEFINED_NODEeileencodes
Ruby code: ```ruby defined?(defined?(a)) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,21)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,21)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined? for PM_BREAK_NODEeileencodes
Ruby code: ```ruby defined?(break) ``` Instructions: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,15)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,15)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[Prism] Implement defined for PM_NEXT_NODEeileencodes
Ruby code: ```ruby defined?(next) ``` Instructions ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(59,15)> 0000 putobject "expression" ( 59)[Li] 0002 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:58 (58,0)-(58,15)> 0000 putobject "expression" ( 58)[Li] 0002 leave ``` Related: ruby/prism#2188
2024-01-17[PRISM] Fix test_compile_prism_with_filePeter Zhu
The test should be testing RubyVM::InstructionSequence.compile_prism with a file but it is instead passing the file path (which is a string) which raises a SyntaxError because it is not Ruby syntax.
2024-01-17[PRISM] Fix stack inconsistency in MultiWriteNodeMatt Valentine-House
2024-01-17Fix off-by-one error of argcNobuyoshi Nakada
Fix ruby/ruby#9562
2024-01-17Omit low-memory test on old platformsNobuyoshi Nakada
2024-01-16[PRISM] Fix crash with empty ensure blocksPeter Zhu
Fixes ruby/prism#2179.
2024-01-16[PRISM] Fix splat assignmentPeter Zhu
Fixes ruby/prism#2177
2024-01-16Fix coderange of invalid_encoding_string.<<(ord)tompng
Appending valid encoding character can change coderange from invalid to valid. Example: "\x95".force_encoding('sjis')<<0x5C will be a valid string "\x{955C}"
2024-01-16[PRISM] Fix defined? for chained callsPeter Zhu
Fixes ruby/prism#2148.
2024-01-16[Bug #20184] Test for low memoryNobuyoshi Nakada
2024-01-15[PRISM] Fix keyword splat inside of arrayPeter Zhu
Fixes ruby/prism#2155.
2024-01-15[PRISM] Fix case without predicatePeter Zhu
Fixes ruby/prism#2149.
2024-01-15Improve behavioural consistency of unallocated (zero length) `IO::Buffer`. ↵Samuel Williams
(#9532) This makes the behaviour of IO::Buffer.new(0) and IO::Buffer.new.slice(0, 0) consistent. Fixes https://bugs.ruby-lang.org/issues/19542 and https://bugs.ruby-lang.org/issues/18805.
2024-01-14Support keyword splatting nilJeremy Evans
nil is treated similarly to the empty hash in this case, passing no keywords and not calling any conversion methods. Fixes [Bug #20064] Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2024-01-14Add test for `Errno` constantsNobuyoshi Nakada
2024-01-12Fix splat assigns with no leftiesAaron Patterson
We still need to emit an expand array even if there's no "left side" variables Fixes: https://github.com/ruby/prism/issues/2153
2024-01-12Update test/ruby/test_compile_prism.rbAaron Patterson
Co-authored-by: Ufuk Kayserilioglu <ufuk@paralaus.com>
2024-01-12[PRISM] Pre-concatenate Strings in InterpolatedStringNodeJemma Issroff
This commit concatenates String VALUEs within InterpolatedStringNodes to allow us to preserve frozenness of concatenated strings such as `"a""b"` Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
2024-01-12[PRISM] Fix splat in whenPeter Zhu
Fixes ruby/prism#2147.
2024-01-11[PRISM] Raise syntax errors when foundKevin Newton
2024-01-11[PRISM] Fix splat inside of asetPeter Zhu
Fixes ruby/prism#2146.
2024-01-11[PRISM] Support repeated required parameter names.Aaron Patterson
Fixes: https://github.com/ruby/prism/issues/2062 This patch only fixes positional parameters, we still need to fix the other cases spelled out in test/prism/fixtures/repeat_parameters.txt
2024-01-11Reject encodings determined at runtime as source code encodingsNobuyoshi Nakada
The encodings determined at runtime are affected by the runtime environment, such as the OS and locale, while the file contents are not.
2024-01-11Prevent syntax warnings in test/ruby/test_regexp.rbYusuke Endoh
2024-01-11Prevent a warning: ambiguous first argumentYusuke Endoh
2024-01-11Add a test for what happens with concurent calls to waitpidKJ Tsanaktsidis
Ruby 3.1 and 3.2 have a bug in their _implementation_, for which I'm backporting a fix. However, the current development branch doesn't have the issue (because the MJIT -> RJIT change refactored how waitpid worked substantially). I do however want to commit the test which verifies that waitpid works properly on master. [Fixes #19387]
2024-01-10Make defined? for op asgn expressions to constants use "assignment"Jeremy Evans
Previously, it used "expression", as that was the default. However, op asgn expressions to constants use the NODE_OP_CDECL, so recognize that node type as assignement. Fixes [Bug #20111]
2024-01-10[PRISM] Don't increment argc for PM_ASSOC_SPLAT_NODEPeter Zhu
Fixes ruby/prism#2087.