summaryrefslogtreecommitdiff
path: root/prism
AgeCommit message (Collapse)Author
2 days[ruby/prism] Fix locations for invalid syntax when using `expect1_opening`Earlopain
Followup to https://github.com/ruby/prism/pull/3827 It sets the start to the opening but it should instead just continue on as usual. Fixes https://github.com/ruby/prism/issues/3851 Notice how the AST actually contains "123" in both the body and end keyword. https://github.com/ruby/prism/commit/8f69c5af08
5 days[ruby/prism] Bump to v1.8.0Takashi Kokubun
https://github.com/ruby/prism/commit/9c12be6e6a
7 days[ruby/prism] [Bug #21831] Fix denominator of rational float literalNobuyoshi Nakada
Denominators can contain underscores in fraction part as well as other numeric literals. [Bug #21831]: https://bugs.ruby-lang.org/issues/21831 https://github.com/ruby/prism/commit/e247cb58c7
2026-01-01[ruby/prism] Fix spacing in the generated #each_child_nodeBenoit Daloze
https://github.com/ruby/prism/commit/91f60cb736
2025-12-29[ruby/prism] Optimize ruby visitorEarlopain
`compact_child_nodes` allocates an array. We can skip that step by simply yielding the nodes. Benchmark for visiting the rails codebase: ```rb require "prism" require "benchmark/ips" files = Dir.glob("../rails/**/*.rb") results = files.map { Prism.parse_file(it) } visitor = Prism::Visitor.new Benchmark.ips do |x| x.config(warmup: 3, time: 10) x.report do results.each do visitor.visit(it.value) end end end RubyVM::YJIT.enable Benchmark.ips do |x| x.config(warmup: 3, time: 10) x.report do results.each do visitor.visit(it.value) end end end ``` Before: ``` ruby 3.4.8 (2025-12-17 revision https://github.com/ruby/prism/commit/995b59f666) +PRISM [x86_64-linux] Warming up -------------------------------------- 1.000 i/100ms Calculating ------------------------------------- 2.691 (± 0.0%) i/s (371.55 ms/i) - 27.000 in 10.089422s ruby 3.4.8 (2025-12-17 revision https://github.com/ruby/prism/commit/995b59f666) +YJIT +PRISM [x86_64-linux] Warming up -------------------------------------- 1.000 i/100ms Calculating ------------------------------------- 7.278 (±13.7%) i/s (137.39 ms/i) - 70.000 in 10.071568s ``` After: ``` ruby 3.4.8 (2025-12-17 revision https://github.com/ruby/prism/commit/995b59f666) +PRISM [x86_64-linux] Warming up -------------------------------------- 1.000 i/100ms Calculating ------------------------------------- 3.429 (± 0.0%) i/s (291.65 ms/i) - 35.000 in 10.208580s ruby 3.4.8 (2025-12-17 revision https://github.com/ruby/prism/commit/995b59f666) +YJIT +PRISM [x86_64-linux] Warming up -------------------------------------- 1.000 i/100ms Calculating ------------------------------------- 16.815 (± 0.0%) i/s (59.47 ms/i) - 169.000 in 10.054668s ``` ~21% faster on the interpreter, ~56% with YJIT https://github.com/ruby/prism/commit/bf631750cf
2025-12-29[ruby/prism] Report missing end errors at opening tokenThomas Marshall
This commit adds an `expect1_opening` function that expects a token and attaches the error to the opening token location rather than the current position. This is useful for errors about missing closing tokens, where we want to point to the line with the opening token rather than the end of the file. For example: ```ruby def foo def bar def baz ^ expected an `end` to close the `def` statement ^ expected an `end` to close the `def` statement ^ expected an `end` to close the `def` statement ``` This would previously produce three identical errors at the end of the file. After this commit, they would be reported at the opening token location: ```ruby def foo ^~~ expected an `end` to close the `def` statement def bar ^~~ expected an `end` to close the `def` statement def baz ^~~ expected an `end` to close the `def` statement ``` I considered using the end of the line where the opening token is located, but in some cases that would be less useful than the opening token location itself. For example: ```ruby def foo def bar def baz ``` Here the end of the line where the opening token is located would be the same for each of the unclosed `def` nodes. https://github.com/ruby/prism/commit/2d7829f060
2025-12-18[ruby/prism] Bump to v1.7.0Kevin Newton
https://github.com/ruby/prism/commit/21c499d6e4
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-18[ruby/prism] Add Ruby 4.1 as a version specifierEarlopain
https://github.com/ruby/prism/commit/138db9ccc4
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-07Ignore distclean failuresNobuyoshi Nakada
Just clean the directory if it exists and is empty.
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-05[ruby/prism] Correct constant pool bucket type logicKevin Newton
When replacing an owned constant by a different type (constant or shared) replace with the correct type instead of defaulting to shared. https://github.com/ruby/prism/commit/fbe9b131a1
2025-12-05[ruby/prism] Avoid undefined int overflow behaviourSteven Johnstone
Fixes https://github.com/ruby/prism/pull/3786. https://github.com/ruby/prism/commit/b72b664675
2025-12-05[ruby/prism] Avoid out-of-bounds readsSteven Johnstone
Fixes https://github.com/ruby/prism/pull/3784. https://github.com/ruby/prism/commit/3fe862534b
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-03[ruby/prism] Follow repo move from oracle/truffleruby to truffleruby/trufflerubyBenoit Daloze
https://github.com/ruby/prism/commit/c8e1b11120
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] Update unicode tables to match that of CRubyKevin Newton
The unicode version has been updated upstream, which means new codepoints mapped to alpha/alnum/isupper flags. We need to update our tables to match. I'm purposefully not adding a version check here, since that is such a large amount of code. It's possible that we could include different tables depending on a macro (like UNICODE_VERSION) or something to that effect, but it's such a minimal impact on the running of the actual parser that I don't think it's necessary. https://github.com/ruby/prism/commit/78925fe5b6
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] Revert "Fix invalid Ruby code example in ClassNode comment"Kevin Newton
https://github.com/ruby/prism/commit/b960079559
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-28[ruby/prism] Fix invalid Ruby code example in ClassNode commentqraqras
https://github.com/ruby/prism/commit/5b7456c8f6
2025-11-27Clean prism directoryNobuyoshi Nakada
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