Skip to content

Releases: ruby/prism

v0.29.0

10 May 17:13
1f49ca9
Compare
Choose a tag to compare

Added

  • Added Prism::CallNode#full_message_loc, which gives the location including the = if there is one.
  • A warning for when # shareable_constant_value is 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 operator have been renamed to binary_operator for *OperatorWriteNode nodes. 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/prism codebase.

v0.28.0

03 May 19:37
64b112c
Compare
Choose a tag to compare

Added

  • Nested hashes will now warn for duplicated keys, as in: { foo: 1, **{ foo: 2 } }.
  • Prism::ReturnNode now has a flag on it to indicate if it is redundant.
  • Prism::Location#slice_lines and Prism::Node#slice_lines are 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 the version: parameter on all Prism.* APIs.
  • Prism::Source#lines, Prism::Location#source_lines, Prism::Node#source_lines, and Prism::Node#script_lines are now provided, which will all return the source code of the source as an array of strings.
  • Prism::ASCIISource is now provided, which is a subclass of Prism::Source but 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 **nil is 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#tunnel is 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#inspect now 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#child and Prism::ConstantTargetNode#child are now deprecated, replaced by two new fields on these nodes: name and name_loc.

v0.27.0

23 Apr 21:15
096d01c
Compare
Choose a tag to compare

Added

  • Implemented === for each of the nodes, which will check if equality but ignore the specific ranges of locations.

Changed

  • Fix translation of ItParametersNode for parser translation.
  • Fix translation of dstr for ruby_parser translation.
  • Do not allow omitted hash values whose keys end with ! or ?.
  • Split up Prism::ParseResult into Prism::Result with subclasses Prism::ParseResult, Prism::LexResult, Prism::ParseLexResult, and Prism::LexCompat::Result.
  • Change reflection classes to have only a single IntegerField class and rename DoubleField to FloatField.
  • Fall back to default AR and CC in Makefile.
  • 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

23 Apr 21:15
b0a4810
Compare
Choose a tag to compare

Added

  • Add Prism::Node::fields, which returns a list of Prism::Reflection::Field objects 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 parser when translating heredocs with interpolation.
  • Fixed RBI and RBS types for Prism::parse_* signatures.
  • Remove some incorrect warnings about unused local variables.
  • More closely match CRuby error messages for global variables.
  • Fix an issue with parser translation when line continuations are found in string literals.

v0.25.0

05 Apr 21:47
225c940
Compare
Choose a tag to compare

Added

  • Prism::Translation::Ripper is now able to mirror all of the Ripper APIs.
  • Prism::Location#leading_comments and Prism::Location#trailing_comments is added.
  • Prism::Comment#slice is added.
  • Warn for writing literal values in conditional predicates.
  • Check for _POSIX_MAPPED_FILES before using mmap.
  • Prism::ItParametersNode is 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 RBI and RBS types.
  • Support for the -p, -n, -a, and -l command 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_XALLOCATOR define.
  • Warn for certain keywrods at the end of the line.
  • Provide pm_visit_node, a C visitor API.
  • Prism::parse_stream is added, which works for any Ruby IO object.
  • 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::ShareableConstantNode added to support ractors.
  • Warn for frozen string literals found after tokens.
  • Support PRISM_BUILD_MINIMAL to 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 -x command line switch.
  • Error messages now much more closely mirror CRuby.
  • Provide syntax errors for invalid block exits (break, next, retry, and yield).
  • 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/parser translation.
  • Accept newlines before pattern terminators ) or ].
  • Prism::Node#start_offset and Prism::Node#end_offset are now much more efficient.
  • Read files using fread instead of mmap when we're going to keep around the source through the Ruby API.
  • Fix Sexp#line_max setting in the seattlerb/ruby_parser translation layer.
  • Allow spaces before the encoding comment.

v0.24.0

15 Feb 20:50
20b0602
Compare
Choose a tag to compare

Added

  • More support for Prism::Translation::Ripper is 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.

v0.23.0

14 Feb 17:58
b68effc
Compare
Choose a tag to compare

Added

  • More support for Prism::RipperCompat is added.
  • A significantly faster offset cache for Prism::Translation::Parser is added for files with multibyte characters.
  • Prism::Translation::RubyParser is added.
  • Prism::ConstantPathTarget#full_name is added.
  • version: "3.4.0" is added as an option that is an alias for version: "latest".
  • Four new APIs are added to Prism::Location:
    • Prism::Location#start_code_units_offset
    • Prism::Location#end_code_units_offset
    • Prism::Location#start_code_units_column
    • Prism::Location#end_code_units_column
  • Invalid multibyte characters are now validated within strings, lists, and heredocs.

Changed

  • When defining def !@, the name_loc was previously only pointing to !, but now includes the @. The name is the same.
  • Prism::RipperCompat has been moved to Prism::Translation::Ripper.
  • Many of the error messages that prism produces have been changed to match the error messages that CRuby produces.

v0.22.0

07 Feb 18:45
1fcec44
Compare
Choose a tag to compare

Added

  • More support for Prism::RipperCompat is added.
  • Support for Ruby 2.7 has been added, and the minimum Ruby requirement has been lowered to 2.7.

Changed

  • The error for an invalid source encoding has a new :argument level to indicate it raises an argument error.
  • BeginNode nodes that are used when a class, singleton class, module, method definition, or block have an inline rescue/ensure/else now have their opening locations set to the beginning of the respective keyword.
  • Improved error messages for invalid characters.
  • Prism.parse_file and similar APIs will raise more appropriate errors when the file does not exist or cannot be mapped.
  • Correctly handle the recover parameter for Prism::Translation::Parser.

v0.21.0

05 Feb 18:02
ff4f83c
Compare
Choose a tag to compare

Added

  • Add the pm_constant_pool_find API for finding a constant.

Changed

  • Fixes for Prism::Translation::Parser.
    • Ensure all errors flow through parser.diagnostics.process.
    • Fix the find pattern node.
    • Fix block forwarding with NumberedParametersNode.
    • Ensure we can parse strings with invalid bytes for the encoding.
    • Fix hash pairs in pattern matching.
  • Properly reject operator writes on operator calls, e.g., a.+ -= b.
  • Fix multi-byte escapes.
  • Handle missing body in begin within the receiver of a method call.

v0.20.0

01 Feb 17:26
cc7567b
Compare
Choose a tag to compare

Added

  • String literal hash keys are now marked as frozen as static literal.
  • IndexTargetNode now always has the ATTRIBUTE_WRITE flag.
  • Call*Node nodes now have an IGNORE_VISIBILITY flag.
  • We now support the it default parameter.
  • Errors and warnings now have levels associated with them.
  • Symbols now have correct encoding flags.
  • We have now merged parser-prism in, which provides translation to the whitequark/parser AST.
  • We now emit errors for invalid method definition receivers.

Changed

  • We now emit errors on invalid pinned local variables.
  • When passed scopes, it is now assumed that the innermost scope is the current binding.
  • We now provide better error recovery for non terminated heredocs.
  • Fix for RationalNode#value for non-decimal integers.
  • Unary symbols !@ and ~@ now unescape to ! and ~, respectively.
  • frozen_string_literal: false now works properly.

Removed

  • We've removed the locals_body_index field.
  • We've removed the verbose option on the various parse APIs. Warnings are now always emitted with their associated level so that consumers can decide how to handle them.