summaryrefslogtreecommitdiff
path: root/test/ruby/test_syntax.rb
AgeCommit message (Collapse)Author
6 daysUse `assert_ruby_status` if no assertionNobuyoshi Nakada
7 daysFluent and/or is supported by Prism too nowNobuyoshi Nakada
2025-09-13Fill in lead num for blocks with `it`Kevin Newton
Fixes [Bug #21256] Co-Authored-By: Earlopain <14981592+Earlopain@users.noreply.github.com>
2025-09-13[Feature #20925] Support leading logical operatorsNobuyoshi Nakada
2025-09-12Update test syntax to handle command call endless methodsKevin Newton
2025-09-12Restore test example for argument forwardingÉtienne Barrié
Since cb419e3912f0514b8151469b0a4a4b83cbbcce78 we're no longer testing this case because foo is redefined on obj1.
2025-07-18Revert "[Bug #21256] Fix `it` parameter when splatting and `define_method` ↵Yusuke Endoh
is…" This reverts commit 265059603c3aa6a13f90096c71b32046a17938f3.
2025-07-17[Bug #21256] Fix `it` parameter when splatting and `define_method` is usedEarlopain
It was failing to set the leads, like numblocks do, causing the result to be wrapped in an array
2025-05-17Add a test case for `it` in a regex.Nick Dower
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com> Notes: Merged: https://github.com/ruby/ruby/pull/13360
2025-05-17[Bug #21313] Handle `it` in rescue and ensure blocks.Nick Dower
The following is crashing for me: ```shell ruby --yjit --yjit-call-threshold=1 -e '1.tap { raise rescue p it }' ruby: YJIT has panicked. More info to follow... thread '<unnamed>' panicked at ./yjit/src/codegen.rs:2402:14: ... ``` It seems `it` sometimes points to the wrong value: ```shell ruby -e '1.tap { raise rescue p it }' false ruby -e '1.tap { begin; raise; ensure; p it; end } rescue nil' false ``` But only when `$!` is set: ```shell ruby -e '1.tap { begin; nil; ensure; p it; end }' 1 ruby -e '1.tap { begin; nil; rescue; ensure; p it; end }' 1 ruby -e '1.tap { begin; raise; rescue; ensure; p it; end }' 1 ``` Notes: Merged: https://github.com/ruby/ruby/pull/13360
2025-01-14[PRISM] Handle forwarding inside evalKevin Newton
Fixes [Bug #21031] Notes: Merged: https://github.com/ruby/ruby/pull/12575
2024-12-23Add a test case for nested block `it`yui-knk
Notes: Merged: https://github.com/ruby/ruby/pull/12435
2024-12-23Revert "[Bug #20965] Define `it` like an ordinary argument" (#12418)Takashi Kokubun
Revert "[Bug #20965] Define `it` like an ordinary argument (#12398)" Reverts ruby/ruby#12398 as per https://bugs.ruby-lang.org/issues/20970#note-6 and https://bugs.ruby-lang.org/issues/20965#note-7. We need more time to design the intended behavior, and it's too late for Ruby 3.4. Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2024-12-18[Bug #20965] Define `it` like an ordinary argument (#12398)Nobuyoshi Nakada
Also fixes [Bug #20955] Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2024-10-16Fix memory leak in syntax error in prismPeter Zhu
If there is a syntax error, there could be an ast_node in the result. This could get leaked if there is a syntax error so parsing could not complete (parsed is not set to true). For example, the following script leaks memory: 10.times do 10_000.times do eval("def foo(...) super(...) {}; end") rescue SyntaxError end puts `ps -o rss= -p #{$$}` end Before: 31328 42768 53856 65120 76208 86768 97856 109120 120208 131296 After: 20944 20944 20944 20944 20944 20944 20944 20944 20944 20944 Notes: Merged: https://github.com/ruby/ruby/pull/11901
2024-10-10Suppress warnings with `RUBYPOT=-w`Nobuyoshi Nakada
``` -:3: warning: assigned but unused variable - var -:3: warning: assigned but unused variable - var -:3: warning: assigned but unused variable - var -:3: warning: assigned but unused variable - var -:3: warning: assigned but unused variable - var -:3: warning: assigned but unused variable - var ```
2024-10-09[Bug #20789] Fix an invalid syntax error when `->a=1...{}`ydah
https://bugs.ruby-lang.org/issues/20789 Notes: Merged: https://github.com/ruby/ruby/pull/11850
2024-10-01[Bug #20764] Refactor argument forwarding in lambdaNobuyoshi Nakada
Reject argument forwarding in lambda: - without parentheses - after optional argument(s) Notes: Merged: https://github.com/ruby/ruby/pull/11751
2024-10-01Fix compile issue with a short-circuited if/unless condition and `defined?`Luke Gruber
This caused an issue when `defined?` was in the `if` condition. Its instructions weren't appended to the instruction sequence even though it was compiled if a compile-time known logical short-circuit happened before the `defined?`. The catch table entry (`defined?` compilation produces a catch table entry) was still on the iseq even though the instructions weren't there. This caused faulty exception handling in the method. The solution is to no add the catch table entry for `defined?` after a compile-time known logical short circuit. This shouldn't touch much code, it's only for cases like the following, which can occur during debugging: if false && defined?(Some::CONSTANT) "more code..." end Fixes [Bug #20501] Notes: Merged: https://github.com/ruby/ruby/pull/11554
2024-09-28Allow dot3 in defs singletontompng
Notes: Merged: https://github.com/ruby/ruby/pull/11716
2024-09-17Fix a typo, sorry!Yusuke Endoh
2024-09-17Prevent two warningsYusuke Endoh
``` /home/chkbuild/chkbuild/tmp/build/20240917T123003Z/ruby/test/ruby/test_case.rb:73: warning: 'when' clause on line 73 duplicates 'when' clause on line 73 and is ignored /home/chkbuild/chkbuild/tmp/build/20240917T123003Z/ruby/test/ruby/test_syntax.rb:333: warning: key :k1 is duplicated and overwritten on line 333 ```
2024-09-13Prevent warnings "the block passed to ... may be ignored"Yusuke Endoh
Notes: Merged: https://github.com/ruby/ruby/pull/11611
2024-08-15[PRISM] test_invalid_jump assertion updates for prismKevin Newton
Notes: Merged: https://github.com/ruby/ruby/pull/11386
2024-07-21Fix a typo in setup of block-after-blockcall testsNobuyoshi Nakada
Unparenthesize the argument and make `command_call` when calling with `do`-block. Notes: Merged: https://github.com/ruby/ruby/pull/11216
2024-07-21Fix SEGV on method call with empty args and brace block for do block command ↵yui-knk
call Notes: Merged: https://github.com/ruby/ruby/pull/11215
2024-06-06Remove circular parameter syntax errorKevin Newton
https://bugs.ruby-lang.org/issues/20478
2024-05-24Update duplicated when clause warning messageKevin Newton
2024-05-22[PRISM] Properly support 'it'Kevin Newton
2024-05-20[PRISM] Enable TestSyntax#test_warn_balancedKevin Newton
2024-05-16[PRISM] Enable TestSyntax#test_syntax_error_at_newlineKevin Newton
2024-05-16[Bug #20468] Fix safe navigation in `for` variableNobuyoshi Nakada
2024-05-08[Bug #20474] Keep spaces in leading blank lineNobuyoshi Nakada
2024-05-07[PRISM] Enable test_methoddef_endless_commandKevin Newton
2024-04-12[Bug #20423] Disallow anonymous block within argument forwardingNobuyoshi Nakada
2024-04-02[Feature #20331] Simplify parser warnings for hash keys duplication and when ↵yui-knk
clause duplication This commit simplifies warnings for hash keys duplication and when clause duplication, based on the discussion of https://bugs.ruby-lang.org/issues/20331. Warnings are reported only when strings are same to ohters.
2024-03-26[Bug #20392] Block arguments duplication check at `super`Nobuyoshi Nakada
2024-02-23[Bug #20295] Fix SEGV when parsing invalid regexpyui-knk
2024-02-20Add pushtoarraykwsplat instruction to avoid unnecessary array allocationJeremy Evans
This is designed to replace the newarraykwsplat instruction, which is no longer used in the parse.y compiler after this commit. This avoids an unnecessary array allocation in the case where ARGSCAT is followed by LIST with keyword: ```ruby a = [] kw = {} [*a, 1, **kw] ``` Previous Instructions: ``` 0000 newarray 0 ( 1)[Li] 0002 setlocal_WC_0 a@0 0004 newhash 0 ( 2)[Li] 0006 setlocal_WC_0 kw@1 0008 getlocal_WC_0 a@0 ( 3)[Li] 0010 splatarray true 0012 putobject_INT2FIX_1_ 0013 putspecialobject 1 0015 newhash 0 0017 getlocal_WC_0 kw@1 0019 opt_send_without_block <calldata!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE> 0021 newarraykwsplat 2 0023 concattoarray 0024 leave ``` New Instructions: ``` 0000 newarray 0 ( 1)[Li] 0002 setlocal_WC_0 a@0 0004 newhash 0 ( 2)[Li] 0006 setlocal_WC_0 kw@1 0008 getlocal_WC_0 a@0 ( 3)[Li] 0010 splatarray true 0012 putobject_INT2FIX_1_ 0013 pushtoarray 1 0015 putspecialobject 1 0017 newhash 0 0019 getlocal_WC_0 kw@1 0021 opt_send_without_block <calldata!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE> 0023 pushtoarraykwsplat 0024 leave ``` pushtoarraykwsplat is designed to be simpler than newarraykwsplat. It does not take a variable number of arguments from the stack, it pops the top of the stack, and appends it to the second from the top, unless the top of the stack is an empty hash. During this work, I found the ARGSPUSH followed by HASH with keyword did not compile correctly, as it pushed the generated hash to the array even if the hash was empty. This fixes the behavior, to use pushtoarraykwsplat instead of pushtoarray in that case: ```ruby a = [] kw = {} [*a, **kw] [{}] # Before [] # After ``` This does not remove the newarraykwsplat instruction, as it is still referenced in the prism compiler (which should be updated similar to this), YJIT (only in the bindings, it does not appear to be implemented), and RJIT (in a couple comments). After those are updated, the newarraykwsplat instruction should be removed.
2024-02-19[Bug #20280] Raise SyntaxError on invalid encoding symbolNobuyoshi Nakada
2024-02-15Do not include a backtick in error messages and backtracesYusuke Endoh
[Feature #16495]
2024-02-13Fix memory leak when parsing invalid hash symbolPeter Zhu
For example: 10.times do 100_000.times do eval('{"\xC3": 1}') rescue EncodingError end puts `ps -o rss= -p #{$$}` end Before: 32032 48464 66112 84192 100592 117520 134096 150656 167168 183760 After: 17120 17120 17120 17120 18560 18560 18560 18560 18560 18560
2024-01-28[Bug #20219] `gettable` returns NULL on errorNobuyoshi Nakada
2024-01-28[Bug #20217] `return` with `ensure` is a void value expressionNobuyoshi Nakada
2024-01-05Add test cases for duplicated `when\' clause warningsyui-knk
Add test cases for `__LINE__` and `__FILE__` because they were managed by NODE_LIT and NODE_STR but changed to be managed by dedicated NODE now.
2024-01-02Introduce NODE_FILEyui-knk
`__FILE__` was managed by `NODE_STR` with `String` object. This commit introduces `NODE_FILE` and `struct rb_parser_string` so that 1. `__FILE__` is detectable from AST Node 2. Reduce dependency ruby object
2024-01-02Warn "literal in condition" for `__LINE__`yui-knk
Print warning for a code like ```ruby if __LINE__ end # => warning: literal in condition ```
2023-12-25suppress a warningNARUSE, Yui
2023-12-25[Feature #19370] Blocks without anonymous parameters should not affectNobuyoshi Nakada
2023-12-25Implement `it` (#9199)Takashi Kokubun
[[Feature #18980]](https://bugs.ruby-lang.org/issues/18980) Co-authored-by: Yusuke Endoh <mame@ruby-lang.org>