Releases: ruby/prism
Releases · ruby/prism
Release list
v1.2.0
Added
- Introduce
Prism::CodeUnitsCache.
Changed
- Properly handle lexing global variables that begin with
$-. - Properly reject invalid multi writes within parentheses.
- Fix unary
*binding power. - Set
contains_keywordsflag for implicitgetscalls when-pis used. - Properly reject invalid non-associative operator patterns.
- Do not warn about unused variables declared on negative lines.
v1.1.0
Added
- Explicitly type each child node field in the Ruby API.
- Add the
main_scriptoption to the parse APIs, which controls whether or not shebangs are considered. - Add the
partial_scriptoptions to the parse APIs, which controls whether or not jumps that would otherwise be considered invalid are allowed. This is useful for parsing things like ERB sources, where you know it will be evaluated in a different context. Note that this functionality is replacing the previous idiom of passing in a list of scopes to indicate anevalcontext, because that behavior has changed upstream inruby/ruby. - Add
ArgumentsNode#contains_multiple_splats?. - Add
ArgumentsNode#contains_forwarding?. - Accept all valid Ruby versions for the
versionoption on parse APIs. - Accept version shorthands like
"3.3"and"3.4"for theversionoption on parse APIs. - Support a max depth to protect against malicious payloads without hitting the stack limit.
Changed
- Fix some token incompatibilities in the
parsertranslation. - Fix up parsing tempfiles on Windows.
- Fix up handling UTF-8 characters in file paths on Windows.
- Do not warn for a
\rat the end of a shebang on Windows. - Properly handle erroring for parsing a directory on Windows.
- When a numbered reference is out of range, warn instead of raise.
- Allow returns in default parameter values.
- Reject many more invalid syntax patterns.
v1.0.0
Added
- Add
Node#breadth_first_search. - Add
Node#node_id. - Add
ArgumentsNode#contains_splat?. - Passing the special value
falsefor theencodingoption tells Prism to ignore magic encoding comments. - Expose flags on every node type (allows checking static literal and newline).
- Implement mismatched indentation warning.
- Add C API for receiving a callback when parsing shebangs with additional flags.
Changed
- BREAKING: Some fields are renamed that had illogical names. The previous names all now emit deprecation warnings.
CaseMatchNode#consequentwas renamed toCaseMatchNode#else_clauseCaseNode#consequentwas renamed toCaseNode#else_clauseIfNode#consequentwas renamed toIfNode#subsequentRescueNode#consequentwas renamed toRescueNode#subsequentUnlessNode#consequentwas renamed toUnlessNode#else_clause
- Block exits are now allowed in loop predicates (e.g.,
while _ && break do end). - Multi-writes are now disallowed when not at the statement level.
- Ensure that range operators are non-associative.
- (JavaScript) Correctly deserialize encoded strings.
- Properly support parsing regular expressions in extended mode.
- Use gmake on FreeBSD.
- Parsing streams now handles NUL bytes in the middle of the stream.
- Properly detect invalid returns.
v0.30.0
Added
- More correctly raise mixed encoding errors.
- Implement ambiguous binary operator warning.
- Fix up regexp escapes with control and meta characters.
- Fix up support for the
itimplicit local variable. - Heredoc identifiers now properly disallow CLRF.
- Errors added for void value expressions in begin clauses.
- Many updates to more closely match the
parsergem in parser translation. - Many errors added for invalid regular expressions.
Changed
- Handle parser translation missing the
parsergem. - Handle ruby_parser translation missing the
ruby_parsergem. - Various error messages have been updated to more closely match CRuby.
RationalNodenow has anumeratoranddenominatorfield instead of anumericfield. For the Ruby API we provide aRationalNode#numericmethod for backwards-compatibility.
v0.29.0
Added
- Added
Prism::CallNode#full_message_loc, which gives the location including the=if there is one. - A warning for when
# shareable_constant_valueis not used on its own line. - An error for invalid implicit local variable writes.
- Implicit hash patterns in array patterns are disallowed.
- We now validate that Unicode escape sequences are not surrogates.
Changed
- All fields named
operatorhave been renamed tobinary_operatorfor*OperatorWriteNodenodes. This is to make it easier to provide C++ support. In the Ruby API, the old fields are aliased to the new fields with a deprecation warning. - Many updated error messages to more closely match CRuby.
- We ensure keyword parameters do not end in
!or?. - Fixed some escaping in string literals with control sequences and hex escapes.
- Fix a bug with RBS types when used outside the
ruby/prismcodebase.
v0.28.0
Added
- Nested hashes will now warn for duplicated keys, as in:
{ foo: 1, **{ foo: 2 } }. Prism::ReturnNodenow has a flag on it to indicate if it is redundant.Prism::Location#slice_linesandPrism::Node#slice_linesare now provided to slice the source code of a node including the content before the node on the same line that it starts on and the content after the node on the same line that it ends on.- Symbols with invalid byte sequences now give errors.
- You can now pass
"3.3.1"to theversion:parameter on allPrism.*APIs. Prism::Source#lines,Prism::Location#source_lines,Prism::Node#source_lines, andPrism::Node#script_linesare now provided, which will all return the source code of the source as an array of strings.Prism::ASCIISourceis now provided, which is a subclass ofPrism::Sourcebut specialized to increase performance when the source is entirely ASCII.- Prism now provides errors when parsing Ruby 3.4+ syntax for index expressions with keywords or blocks.
- Prism now provides an error when
**nilis used after other keyword parameters. - Prism now provides errors when safe navigation is used in call target expressions, e.g.,
foo&.bar, = 1. Prism::Node#tunnelis now provided, which returns an array of nodes starting at the current node that contain a given line and column.
Changed
- All translation layers now assume an eval context, which means they will not return errors for invalid jumps like
yield. Prism::Node#inspectnow uses a queue instead of recursion to avoid stack overflows.- Prism now more closely mirrors CRuby interpolation semantics, which means you could potentially have a static literal string that directly interpolates another static literal string.
- The shipped RBI sorbet types no longer use generics.
Prism::ConstantPathNode#childandPrism::ConstantTargetNode#childare now deprecated, replaced by two new fields on these nodes:nameandname_loc.
v0.27.0
Added
- Implemented
===for each of the nodes, which will check if equality but ignore the specific ranges of locations.
Changed
- Fix translation of
ItParametersNodefor parser translation. - Fix translation of
dstrfor ruby_parser translation. - Do not allow omitted hash values whose keys end with
!or?. - Split up
Prism::ParseResultintoPrism::Resultwith subclassesPrism::ParseResult,Prism::LexResult,Prism::ParseLexResult, andPrism::LexCompat::Result. - Change reflection classes to have only a single
IntegerFieldclass and renameDoubleFieldtoFloatField. - Fall back to default
ARandCCinMakefile. - Use GC-able symbols for the syntax tree to avoid adding to the global symbol table.
- Fix a bug with karatsuba_multiply that would result in a stack overflow.
- Fix parser translation when looking for tokens with
srange_find.
v0.26.0
Added
- Add
Prism::Node::fields, which returns a list ofPrism::Reflection::Fieldobjects representing the fields of the node class. This is useful in metaprogramming contexts. Prism::Location#chop, for removing the last byte from a location.- The void statement warning is now implemented.
- The unreachable statement warning is now implemented.
- A syntax error has been added for block arguments on yields, e.g.,
yield(&foo).
Changed
- Better fidelity to
parserwhen translating heredocs with interpolation. - Fixed
RBIandRBStypes forPrism::parse_*signatures. - Remove some incorrect warnings about unused local variables.
- More closely match CRuby error messages for global variables.
- Fix an issue with
parsertranslation when line continuations are found in string literals.
v0.25.0
Added
Prism::Translation::Ripperis now able to mirror all of the Ripper APIs.Prism::Location#leading_commentsandPrism::Location#trailing_commentsis added.Prism::Comment#sliceis added.- Warn for writing literal values in conditional predicates.
- Check for
_POSIX_MAPPED_FILESbefore usingmmap. Prism::ItParametersNodeis added, to support-> { it }.- Parse integer and float literal values onto the tree.
- Warn on duplicated hash keys and duplicated when clauses.
- Ship much improved
RBIandRBStypes. - Support for the
-p,-n,-a, and-lcommand line switches. - Warn on integer literals in flip-flops.
- Support BSD make.
- Add
Prism::WhenNode#then_keyword_loc. - Support custom allocation functions through the
PRISM_XALLOCATORdefine. - Warn for certain keywrods at the end of the line.
- Provide
pm_visit_node, a C visitor API. Prism::parse_streamis added, which works for any RubyIOobject.- Provide flags for regular expression literals for their derived encoding.
- Provide flags for whether or not an interpolated string literal is frozen.
- Add
Prism::StringNode.mutable?for when a string is explicitly mutable, to support delineating chilled strings. - Warn for incorrect character literal syntax.
- Warn for chained comparison operators.
- Warn for
**interpreted as an argument prefix. - Warn for
&interpreted as an argument prefix. Prism::ShareableConstantNodeadded to support ractors.- Warn for frozen string literals found after tokens.
- Support
PRISM_BUILD_MINIMALto provide only the minimal necessary functionality to reduce the binary size. - Handle CLRF inside heredocs, strings, and regular expressions.
- Mark inner strings in interpolated strings as frozen.
- Support the
-xcommand line switch. - Error messages now much more closely mirror CRuby.
- Provide syntax errors for invalid block exits (
break,next,retry, andyield). - Warn on unused local variables.
- Do not syntax error on default parameter values that only write to the parameter.
Changed
- Many improvements to the compatibility with the
whitequark/parsertranslation. - Accept newlines before pattern terminators
)or]. Prism::Node#start_offsetandPrism::Node#end_offsetare now much more efficient.- Read files using
freadinstead ofmmapwhen we're going to keep around the source through the Ruby API. - Fix
Sexp#line_maxsetting in theseattlerb/ruby_parsertranslation layer. - Allow spaces before the encoding comment.
v0.24.0
Added
- More support for
Prism::Translation::Ripperis added. - Support multiple versions for
Prism::Translation::Parser. - Improved memory usage in the FFI backend.
- Very large speed and memory improvements for creating the Ruby AST.
Changed
- Fix location for empty symbol in hash key.
- Fix parsing a rescue modifier on the value of an assignment when the LHS is a method call with arguments and no parentheses.