Skip to content

Releases: ruby/prism

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.

v0.19.0

14 Dec 20:10
53ef1e8
Compare
Choose a tag to compare

Added

  • ArrayNode now has a contains_splat? flag if it has a splatted element in it.
  • All of the remaining encodings have been implemented.
  • Allow forwarding & in a method that has a ... parameter.
  • Many statements that are found in non-statement positions are being properly rejected now.
  • Void values are now properly checked.
  • Referencing a parameter in its own default value is now properly rejected.
  • DATA/__END__ is now parsed as its own field on parse result (data_loc) as opposed to as a comment.
  • Blank * now properly forwards into arrays.
  • ImplicitRestNode is introduced to represent the implicit rest of a destructure.
  • We now support negative start lines.
  • StringNode#heredoc?, InterpolatedStringNode#heredoc?, XStringNode#heredoc?, and InterpolatedXStringNode#heredoc? are introduced.
  • NumberedParametersNode is introduced to represent the implicit set of parameters when numbered parameters are used.
  • Prism::parse_success? and Prism::parse_failure? are introduced to bypass reifying the AST.
  • We now emit a warning for constant assignments in method definitions.
  • We now provide flags on strings and xstrings to indicate the correct encoding.
  • The hash pattern rest field now more accurately parses ** and **nil.
  • The equality operators are now properly parsed as non-associative.

Changed

  • BREAKING: Many fields have changed positions within their nodes. This impacts the C API and the Ruby API if you are manually creating nodes through the initializer.
  • BREAKING: Almost all of the error messages have been updated to begin with lowercase characters to match ruby/spec.
  • Unterminated strings with only plain content are now always StringNode as opposed to InterpolatedStringNode
  • BREAKING: Call node has been split up when it is in the target position into CallTargetNode and IndexTargetNode.

v0.18.0

21 Nov 19:07
6ca8896
Compare
Choose a tag to compare

Added

  • The ParametersNode#signature method is added, which returns the same thing as Method#parameters.
  • Visitor functionality has been added to the JavaScript API.
  • The Node#to_dot API has been added to convert syntax trees to Graphviz digraphs.
  • IfNode and UnlessNode now have a then_keyword_loc field.
  • Many more encodings are now supported.
  • Some new Location APIs have been added for dealing with characters instead of bytes, which are: start_character_offset, end_character_offset, start_character_column, and end_character_column.
  • A warning has been added for when END {} is used within a method.
  • ConstantPathNode#full_name{,_parts} will now raise an error if the receiver of the constant path is not itself a constant.
  • The in keyword and the => operator now respect non-associativity.
  • The .. and ... operators now properly respect non-associativity.

Changed

  • Previously ... in blocks was accepted, but it is now properly rejected.
  • BREAKING: librubyparser.* has been renamed to libprism.* in the C API.
  • We now properly reject floats with exponent and rational suffixes.
  • We now properly reject void value expressions.
  • BREAKING: The --disable-static option has been removed from the C extension.
  • The rescue modifier keyword is now properly parsed in terms of precedence.
  • We now properly reject defining a numbered parameter method.
  • BREAKING: MatchWriteNode now has a list of targets, which are local variable target nodes. This is instead of locals which was a constant list. This is to support writing to local variables outside the current scope. It has the added benefit of providing location information for the local variable targets.
  • BREAKING: CaseNode has been split into CaseNode and CaseMatchNode, the latter is used for case ... in expressions.
  • BREAKING: StringConcatNode has been removed in favor of using InterpolatedStringNode as a list.

v0.17.1

03 Nov 18:00
d76f295
Compare
Choose a tag to compare

Changed

  • Do not use constant nesting in RBI files.

v0.17.0

03 Nov 15:22
08710a8
Compare
Choose a tag to compare

Added

  • We now properly support forwarding arguments into arrays, like def foo(*) = [*].
  • We now have much better documentation for the C and Ruby APIs.
  • We now properly provide an error message when attempting to assign to numbered parameters from within regular expression named capture groups, as in /(?<_1>)/ =~ "".

Changed

  • BREAKING: KeywordParameterNode is split into OptionalKeywordParameterNode and RequiredKeywordParameterNode. RequiredKeywordParameterNode has no value field.
  • BREAKING: Most of the Prism:: APIs now accept a bunch of keyword options. The options we now support are: filepath, encoding, line, frozen_string_literal, verbose, and scopes. See the pull request for more details.
  • BREAKING: Comments are now split into three different classes instead of a single class, and the type field has been removed. They are: InlineComment, EmbDocComment, and DATAComment.

v0.16.0

30 Oct 16:39
f4a464e
Compare
Choose a tag to compare

Added

  • InterpolatedMatchLastLineNode#options and MatchLastLineNode#options are added, which are the same methods as are exposed on InterpolatedRegularExpressionNode and RegularExpressionNode.
  • The project can now be compiled with wasi-sdk to expose a WebAssembly interface.
  • ArgumentsNode#keyword_splat? is added to indicate if the arguments node has a keyword splat.
  • The C API pm_prettyprint has a much improved output which lines up closely with Node#inspect.
  • Prism now ships with RBS and RBI type signatures (in the /sig and /rbi directories, respectively).
  • Prism::parse_comments and Prism::parse_file_comments APIs are added to extract only the comments from the source code.

Changed

  • BREAKING: Multi{Target,Write}Node#targets is split up now into lefts, rest, and rights. This is to avoid having to scan the list in the case that there are splat nodes.
  • Some bugs are fixed on Multi{Target,Write}Node accidentally creating additional nesting when not necessary.
  • BREAKING: RequiredDestructuredParameterNode has been removed in favor of using MultiTargetNode in those places.
  • BREAKING: HashPatternNode#assocs has been renamed to HashPatternNode#elements. HashPatternNode#kwrest has been renamed to HashPatternNode#rest.

v0.15.1

30 Oct 15:54
d906a8c
Compare
Choose a tag to compare

Changed

  • Fix compilation warning on assigning to bitfield.