summaryrefslogtreecommitdiff
path: root/prism
AgeCommit message (Collapse)Author
2025-11-20[ruby/prism] Use memmove for overlapping memory rangesSteven Johnstone
Fixes https://github.com/ruby/prism/pull/3736. https://github.com/ruby/prism/commit/1f5f192ab7
2025-11-19[ruby/prism] Add docs for super nodesAlexander Momchilov
https://github.com/ruby/prism/commit/69abcdbb18
2025-11-16Handle deeply nested capture variables syntax errKevin Newton
When there are nested capture variables inside of a pattern match that has an alternation pattern, it is a syntax error. Currently it only adds a syntax error when it is at the top level of the pattern.
2025-11-14[ruby/prism] Reject endless method as a block parameter defaultEarlopain
Fixes [Bug #21661] https://github.com/ruby/prism/commit/475fa46a82
2025-11-14[Feature #21572] Syntax error at capture in alternation patternNobuyoshi Nakada
Should fail even with `-c` option.
2025-11-08[ruby/prism] Rename Ruby 3.5 to Ruby 4.0Earlopain
See https://github.com/ruby/ruby/commit/6d81969b475262aba251e99b518181bdf7c5a523 It leaves the old variant around. RuboCop for examples accesses `Prism::Translation::Parser35` to test against ruby-head. For now I left these simply as an alias https://github.com/ruby/prism/commit/d0a823f045
2025-11-07Prism update for 4.0Nobuyoshi Nakada
2025-11-06[ruby/prism] Reject `def f a, (b) = 1`Earlopain
Fixes [#Bug 21660], followup to https://github.com/ruby/prism/pull/3674 https://github.com/ruby/prism/commit/fb445a49e5 Co-Authored-By: tomoya ishida <tomoyapenguin@gmail.com>
2025-10-30[ruby/prism] Add equal_loc to call nodesKevin Newton
In the case of attribute writes, there are use cases where you want to know the location of the = sign. (Internally we actually need this for translation to the writequark AST.) https://github.com/ruby/prism/commit/bfc798a7ec
2025-10-30[ruby/prism] Unescape unary method callsEarlopain
Followup to https://github.com/ruby/prism/pull/2213 Before: ```sh $ ruby -ve "puts 42.~@" ruby 3.4.6 (2025-09-16 revision https://github.com/ruby/prism/commit/dbd83256b1) +PRISM [x86_64-linux] -e:1:in '<main>': undefined method '~@' for an instance of Integer (NoMethodError) Did you mean? ~ ``` After (matches parse.y): ```sh $ ./miniruby -ve "puts 42.~@" ruby 3.5.0dev (2025-10-16T03:40:45Z master https://github.com/ruby/prism/commit/1d95d75c3f) +PRISM [x86_64-linux] -43 ``` https://github.com/ruby/prism/commit/a755bf228f
2025-10-22[ruby/prism] Make error and snapshot tests multi-version awareEarlopain
This one has been on my mind for a while now. Currently, there are only tests against the latest syntax version. This changes the snapshot structure as follows: * Snapshots at their current location are tested against all syntax versions * Snapshots inside a version folder like "3.3" are tested against all versions starting from that version * Snapshots inside a version folder like "3.3-4.2" are tested against all versions in the given range. This makes sure that as new syntax is added, older versions still work as expected. I also added a few tests for now valid syntax that should be invalid in older versions (and the other way around as well) These tests run really fast. So even though it does 3x the work for these, I am still able to run the whole test suite in just 11 seconds. https://github.com/ruby/prism/commit/5191b1aa68
2025-10-16[ruby/prism] Create a new string for the current version errorKevin Newton
https://github.com/ruby/prism/commit/ebf4425d49
2025-10-16[ruby/prism] Bump to v1.6.0Kevin Newton
https://github.com/ruby/prism/commit/b72fcc6183
2025-10-16[ruby/prism] Add support for `Prism.parse(foo, version: "current")`Earlopain
The docs currently say to use `Prism.parse(foo, version: RUBY_VERSION)` for this. By specifying "current" instead, we can have prism raise a more specifc error. Note: Does not use `ruby_version` from `ruby/version.h` because writing a test for that is not really possible. `RUBY_VERSION` is nicely stubbable for both the c-ext and FFI backend. https://github.com/ruby/prism/commit/9c5cd205cf
2025-10-15[ruby/prism] explicitly cast constants in initializers as wellNathan Froyd
https://github.com/ruby/prism/commit/e7db2b06ab
2025-10-15[ruby/prism] explicitly cast shifted constant to unsigned to avoid undefined ↵Nathan Froyd
behavior https://github.com/ruby/prism/commit/0b2710a6c9
2025-10-09[ruby/prism] Bump to vKevin Newton
https://github.com/ruby/prism/commit/7574837b7b
2025-10-08[ruby/prism] For these special cases, there exists no optional argument ↵Earlopain
type. Since a endless method is started with `=`, there was ambiguity here. We have to simply reject these in all cases. This adds a new error for the following reason: * `def foo arg = nil` is interpreted as a normal method call with optional `arg` without matching `end` * `def foo *arg = nil; end` is interpreted as a endless method call that has body `nil` with extraneous `end` `def foo *arg = nil` is somewhere inbetween and I don't know how to otherwise indicate the error. Now the second case above also shows the newly added error message. Fixes [Bug #21623] https://github.com/ruby/prism/commit/e1910d4492
2025-10-06[ruby/prism] Free current_block_exits for the programPeter Zhu
We need to free the current_block_exits in parse_program when we're done with it to prevent memory leaks. This fixes the following memory leak detected when running Ruby using `RUBY_FREE_AT_EXIT=1 ruby -nc -e "break"`: Direct leak of 32 byte(s) in 1 object(s) allocated from: #0 0x5bd3c5bc66c8 in realloc (miniruby+0x616c8) (BuildId: https://github.com/ruby/prism/commit/ba6a96e5a060) #1 0x5bd3c5f91fd9 in pm_node_list_grow prism/templates/src/node.c.erb:35:40 #2 0x5bd3c5f91e9d in pm_node_list_append prism/templates/src/node.c.erb:48:9 #3 0x5bd3c6001fa0 in parse_block_exit prism/prism.c:15788:17 #4 0x5bd3c5fee155 in parse_expression_prefix prism/prism.c:19221:50 #5 0x5bd3c5fe9970 in parse_expression prism/prism.c:22235:23 #6 0x5bd3c5fe0586 in parse_statements prism/prism.c:13976:27 #7 0x5bd3c5fd6792 in parse_program prism/prism.c:22508:40 https://github.com/ruby/prism/commit/fdf9b8d24a
2025-10-01Interpolation with only string literals must not be frozenEarlopain
Basically a redo of https://github.com/ruby/ruby/commit/a1403fb7cbd1fe0df97c932be9814c86081783dc but respecting the frozen string literal magic comment Fixes [Bug #21187]
2025-10-01[ruby/prism] Add a "LAST" enum field to all flags enumsAaron Patterson
This allows us to use the "last" of the enums in order to make masks, etc. This particular commit uses the call flag's last enum field as an offset so that we can define "private" flags but not accidentally clobber any newly added call node flags. https://github.com/ruby/prism/commit/e71aa980d8
2025-09-19[ruby/prism] Reject argument command call taking a block with more trailing ↵Earlopain
arguments https://bugs.ruby-lang.org/issues/21168#note-5 The added code samples align with `parse.y`, except for `foo(bar baz do end)` which `parse.y` currently rejects but shouldn't. https://github.com/ruby/prism/commit/3a4e102d80
2025-09-19[ruby/prism] Fix dangling pointers on Windows as wellNobuyoshi Nakada
Share the empty source string in `pm_string_mapped_init` and `pm_string_file_init`. https://github.com/ruby/prism/commit/f7a9a03a92
2025-09-18[ruby/prism] Fix example marker for case statement predicateRandy Stauner
https://github.com/ruby/prism/commit/2ddedf650a
2025-09-17[ruby/prism] Reject `1 if foo = bar baz`Earlopain
and also `1 and foo = bar baz` This is a partial fix for https://github.com/ruby/prism/issues/3106 It still accepts `a = b c and 1` https://github.com/ruby/prism/commit/7a13d3535b
2025-09-15[ruby/prism] Fix character literal forced encodingKevin Newton
If a character literal was followed by a string concatenation, then the forced encoding of the string concatenation could accidentally overwrite the explicit encoding of the character literal. We now handle this properly. https://github.com/ruby/prism/commit/125c375d74
2025-09-15Make PRISM_BUILD_DIR even when baseruby is availableNobuyoshi Nakada
It is needed before updating the timestamp for prism/srcs.mk.
2025-09-13[ruby/prism] Bump to v1.5.1Kevin Newton
https://github.com/ruby/prism/commit/cac5118884
2025-09-13[ruby/prism] Revert "Merge pull request #3606 from tenderlove/clear-flags"Takashi Kokubun
This reverts commit https://github.com/ruby/prism/commit/4052d93cf852, reversing changes made to https://github.com/ruby/prism/commit/47143d17b3f7. https://github.com/ruby/prism/commit/f117ec6354
2025-09-13Fix dangling pointersNobuyoshi Nakada
2025-09-13Just touch the timestamp for prism/srcs.mk when no baserubyNobuyoshi Nakada
2025-09-12[ruby/prism] Bump to v1.5.0Kevin Newton
https://github.com/ruby/prism/commit/194edab827
2025-09-12[ruby/prism] Add `\memberof` annotationsAlexander Momchilov
https://github.com/ruby/prism/commit/d1d2161219
2025-09-12[ruby/prism] [Bug #17398] Allow `private def hello = puts "Hello"`Earlopain
This was a limitation of parse.y that prism intentionally replicated. https://github.com/ruby/prism/commit/8fd12d594c
2025-09-12[ruby/prism] Add links to code refs in docsAlexander Momchilov
https://github.com/ruby/prism/commit/d2d9a1f1a7
2025-09-12[ruby/prism] Support leading logical operatorsKevin Newton
https://github.com/ruby/prism/commit/3f58fa7705
2025-09-12[ruby/prism] Document lifetime of `pm_options_t`Alexander Momchilov
https://github.com/ruby/prism/commit/ed8f6307c1
2025-09-12[ruby/prism] Add field documentation for PinnedExpressionNodeHerwin
https://github.com/ruby/prism/commit/0d94291416
2025-09-12[ruby/prism] Add field documentation for PinnedVariableNodeHerwin
https://github.com/ruby/prism/commit/af9047f378
2025-09-12[ruby/prism] Add field documentation for FindPatternNodeHerwin
https://github.com/ruby/prism/commit/a0cc316e91
2025-09-12[ruby/prism] Add field documentation for HashPatternNodeHerwin
https://github.com/ruby/prism/commit/9b7dfcc3e0
2025-09-12[ruby/prism] Add field documentation for ArrayPatternNodeHerwin
https://github.com/ruby/prism/commit/c80c4d958e
2025-09-12[ruby/prism] Add pattern match documentation example to LocalVariableTargetNodeHerwin
https://github.com/ruby/prism/commit/193984b760
2025-09-12[ruby/prism] Add field documentation for MatchRequiredNodeHerwin
https://github.com/ruby/prism/commit/03ca35b3ab
2025-09-12Revert "Just touch the timestamp for prism/srcs.mk when no baseruby"Takashi Kokubun
This reverts commit 5a2cedd051634d6d1c8fbf48b0327f8cd8eec495. The CI is telling us to revert the diff: https://github.com/ruby/ruby/actions/runs/17679836157/job/50251138515
2025-09-12Just touch the timestamp for prism/srcs.mk when no baserubyNobuyoshi Nakada
2025-09-11[ruby/prism] Reject some cases with `return` and command callsEarlopain
The same also applies to `break`/`next`. https://bugs.ruby-lang.org/issues/21540 https://github.com/ruby/prism/commit/3a38b192e3
2025-09-11[ruby/prism] Use pm_arguments_end for function callYusuke Endoh
Previously, the location of CallNode was incorrect when it accepts a block parameter: ``` $ ruby -rprism -e 'pp Prism.parse("foo(&blk)").value.statements.body[0]'] @ CallNode (location: (1,0)-(1,8)) # <=== It should be (1,0)-(1,9) ├── flags: ∅ ├── receiver: ∅ ├── call_operator_loc: ∅ ├── name: :foo ├── message_loc: (1,0)-(1,3) = "foo" ├── opening_loc: (1,3)-(1,4) = "(" ├── arguments: ∅ ├── closing_loc: (1,8)-(1,9) = ")" *snip* $ ruby -rprism -e 'pp Prism.parse("foo(&blk)").value.statements.body[0].slice' "foo(&blk" ``` Note that the slice lacks the closing parenthesis. https://github.com/ruby/prism/commit/3c22e6fc39
2025-08-29Remove no longer used file [ci skip]Nobuyoshi Nakada
2025-08-19Gererate prism source files dependencies from template.rbNobuyoshi Nakada
Update included file list automatically.