summaryrefslogtreecommitdiff
path: root/prism/prism.c
AgeCommit message (Collapse)Author
2026-03-16[ruby/prism] Fix not binding power in endless methods [Backport #21097]Takashi Kokubun
Change rescue modifier binding power from PM_BINDING_POWER_COMPOSITION to PM_BINDING_POWER_MATCH + 1, so that `x = a rescue b in c` is parsed as `(x = (a rescue b)) in c` and `def f = a rescue b in c` is parsed as `(def f = (a rescue b)) in c`. https://github.com/ruby/prism/commit/7e797f59ae
2026-03-06[ruby/prism] Fix in handlingKevin Newton
in is a unique keyword because it can be the start of a clause or an infix keyword. We need to be explicitly sure that even though in _could_ close an expression context (the body of another in clause) that we are not also parsing an inline in. The exception is the case of a command call, which can never be the LHS of an expression, and so we must immediately exit. [Bug #21925] [Bug #21674] https://github.com/ruby/prism/commit/20374ced51
2026-03-06[ruby/prism] Fix error message for block/lambda with `...` argumentEarlopain
They currently complain that the parent method is not forwarding. But the actual problem is that these types of arguments simply don't accept `...` Fixes [Bug #21927] https://github.com/ruby/prism/commit/0aa2363331
2026-03-06[ruby/prism] Correctly handle `and?` and similar on ruby 4.0Earlopain
It gets confused for syntax introduced in https://bugs.ruby-lang.org/issues/20925 But it actually should be a plain method call. `!`/`?` are not valid as part of an identifier, methods however allow them as the last character. Fixes [Bug #21946] https://github.com/ruby/prism/commit/5d80bc5e1a
2026-01-12Sync Prism to 1.8.0Takashi Kokubun
2025-12-18[ruby/prism] Reject `p(p a, &block => value)` and similarEarlopain
Redo of https://github.com/ruby/prism/pull/3669 with more tests https://github.com/ruby/prism/commit/48b403ea79
2025-12-15[ruby/prism] Unreference before destroying in call node in patternKevin Newton
https://github.com/ruby/prism/commit/609c80c91e
2025-12-15[ruby/prism] Escape error location is incorrect for some regexKevin Newton
When you have a regular expression that has a named capture that has an escape sequence in the named capture, and that escape sequence is a unicode escape sequence with an invalid surrogate pair, the error was attached to the owned string as opposed to a location on the shared source. https://github.com/ruby/prism/commit/793a7a6a0a
2025-12-14[ruby/prism] Only set location end when it is largerKevin Newton
https://github.com/ruby/prism/commit/65595d6c2c
2025-12-14[ruby/prism] Unreference the block node before destroying itKevin Newton
https://github.com/ruby/prism/commit/fc150b1588
2025-12-13[ruby/prism] Prevent an infinite loop parsing a capture nameSteven Johnstone
Fixes https://github.com/ruby/prism/pull/3729. https://github.com/ruby/prism/commit/6e5347803c
2025-12-09[ruby/prism] Nested heredoc with newline terminatorKevin Newton
When you have a heredoc interpolated into another heredoc where the inner heredoc is terminated by a newline, you need to avoid adding the newline character a second time. https://github.com/ruby/prism/commit/8eeb5f358b
2025-12-09[ruby/prism] Fully handle unreferencing a block exitKevin Newton
If a block exit has a further block exit in its subtree, we need to keep recursing. https://github.com/ruby/prism/commit/855d81a4a8
2025-12-09[ruby/prism] Fix up call target node when invalidKevin Newton
When there is an invalid syntax tree, we need to make sure to fill in the required call operator location. https://github.com/ruby/prism/commit/937313d7f0
2025-12-09[ruby/prism] Fix hash pattern location when missing nodesKevin Newton
https://github.com/ruby/prism/commit/0ad30561e2
2025-12-06[ruby/prism] Avoid out-of-bounds readsSteven Johnstone
Fixes https://github.com/ruby/prism/pull/3790. https://github.com/ruby/prism/commit/173ccb84ad
2025-12-04[ruby/prism] Fix `%Q` with newline delimiter and heredoc interpolationEarlopain
The lexer did not jump to the `heredoc_end`, causing the heredoc end delimiter to be parsed twice. Normally the heredocs get flushed when a newline is encountered. But because the newline is part of the string delimiter, that codepath is not taken. Fixes [Bug #21758] https://github.com/ruby/prism/commit/7440eb4b11
2025-12-03[ruby/prism] Fix wrong error message for lower percent i arraysEarlopain
Not so sure how to trigger it but this is definitly more correct. https://github.com/ruby/prism/commit/1bc8ec5e5d
2025-12-03[ruby/prism] Correctly handle line continuations in %w/i% interrupted by ↵Earlopain
heredocs See https://bugs.ruby-lang.org/issues/21756. Ripper fails to parse this, but prism actually also doesn't handle it correctly. When heredocs are used, even in lowercase percent arays there can be multiple `STRING_CONTENT` tokens. We need to concat them. Luckily we don't need to handle as many cases as in uppercase arrays where interpolation is allowed. https://github.com/ruby/prism/commit/211677000e
2025-12-02[ruby/prism] Consolidate macro definitionsKevin Newton
https://github.com/ruby/prism/commit/cc0ca08757
2025-12-02[ruby/prism] Remove PM_OPTIONAL_LOCATION_NOT_PROVIDED_VALUE macroKevin Newton
https://github.com/ruby/prism/commit/1988615ce1
2025-12-02[ruby/prism] Further specialize PM_NODE_INITKevin Newton
https://github.com/ruby/prism/commit/7ab6d9df47
2025-12-02[ruby/prism] Introduce PM_NODE_FLAGS macroKevin Newton
https://github.com/ruby/prism/commit/a20afe1674
2025-12-02[ruby/prism] Specialize PM_NODE_INIT to reduce calls to locationKevin Newton
https://github.com/ruby/prism/commit/3e0b5c9eb7
2025-12-02[ruby/prism] Introduce PM_NODE_UPCAST macro for readabilityKevin Newton
https://github.com/ruby/prism/commit/7eb169513a
2025-12-01[ruby/prism] PM_NODE_INITKevin Newton
Hide the initialization of the base node inside the node initializer lists by a macro. As such, consistently enforce flags are set properly. https://github.com/ruby/prism/commit/c7b3d66d84
2025-12-01[ruby/prism] Fix up newlines in newline-delimited-literalsKevin Newton
When you have a %-literal that is delimited by newlines, and you are also interpolating a heredoc into that literal, then both concepts will attempt to add the same newline to the newline list. https://github.com/ruby/prism/commit/c831abb888
2025-12-01[ruby/prism] Properly remove referencesKevin Newton
https://github.com/ruby/prism/commit/17b246fd6a
2025-11-30[ruby/prism] Ensure implicit parameter nodes are destroyed.Kevin Newton
When we are about to destroy a node because of a syntax error, we need to check if it is potentially containing an implicit parameter in its subtree. https://github.com/ruby/prism/commit/1531433e02
2025-11-30[ruby/prism] Fully destroy call operator write argumentsKevin Newton
If we are about to delete a call operator write argument, it needs to be removed from the list of block exits as well. https://github.com/ruby/prism/commit/ebc91c2e39
2025-11-29[ruby/prism] Fix out-of-bounds read in parser_lex_magic_commentKevin Newton
https://github.com/ruby/prism/commit/e24e701f3a Co-authored-by: Steven Johnstone <steven.james.johnstone@gmail.com>
2025-11-29[ruby/prism] Fix label interpolated stringKevin Newton
https://github.com/ruby/prism/commit/e3e2b1ed04
2025-11-29[ruby/prism] Fix out-of-bounds read after utf-8 BOMKevin Newton
https://github.com/ruby/prism/commit/198080c106 Co-authored-by: Steven Johnstone <steven.james.johnstone@gmail.com>
2025-11-29[ruby/prism] Handle invalid string pattern keyKevin Newton
When a pattern match is using a string as a hash pattern key and is using it incorrectly, we were previously assuming it was a symbol. In the case of an error, that's not the case. So we need to add a missing node in this case. https://github.com/ruby/prism/commit/f0b06d6269
2025-11-23[ruby/prism] Revert "Reject `p(p a, &block => value)` and similar"Kevin Newton
https://github.com/ruby/prism/commit/fef2c20777
2025-11-23[ruby/prism] Handle destroying implicit parameterKevin Newton
Fixes https://github.com/ruby/prism/pull/3740 https://github.com/ruby/prism/commit/464a849184
2025-11-23[ruby/prism] Avoid reading out-of-bounds in pm_strnstrSteven Johnstone
Fixes https://github.com/ruby/prism/pull/3738. https://github.com/ruby/prism/commit/37bb46ff5f
2025-11-23[ruby/prism] Reject `p(p a, &block => value)` and similarEarlopain
They were being parsed as `p((p a, &block) => value)`. When we get to this point, we must not just have parsed a command call, always consuming the `=>` is not correct. Closes [Bug #21622] https://github.com/ruby/prism/commit/796ab0edf4
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-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-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-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-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