Releases: ruby/prism
Releases · ruby/prism
v0.19.0
Added
ArrayNode
now has acontains_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?
, andInterpolatedXStringNode#heredoc?
are introduced.NumberedParametersNode
is introduced to represent the implicit set of parameters when numbered parameters are used.Prism::parse_success?
andPrism::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 toInterpolatedStringNode
- BREAKING: Call node has been split up when it is in the target position into
CallTargetNode
andIndexTargetNode
.
v0.18.0
Added
- The
ParametersNode#signature
method is added, which returns the same thing asMethod#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
andUnlessNode
now have athen_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
, andend_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 tolibprism.*
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 oftargets
, which are local variable target nodes. This is instead oflocals
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 intoCaseNode
andCaseMatchNode
, the latter is used forcase ... in
expressions. - BREAKING:
StringConcatNode
has been removed in favor of usingInterpolatedStringNode
as a list.
v0.17.1
v0.17.0
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 intoOptionalKeywordParameterNode
andRequiredKeywordParameterNode
.RequiredKeywordParameterNode
has novalue
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
, andscopes
. 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
, andDATAComment
.
v0.16.0
Added
InterpolatedMatchLastLineNode#options
andMatchLastLineNode#options
are added, which are the same methods as are exposed onInterpolatedRegularExpressionNode
andRegularExpressionNode
.- 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 withNode#inspect
. - Prism now ships with
RBS
andRBI
type signatures (in the/sig
and/rbi
directories, respectively). Prism::parse_comments
andPrism::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 intolefts
,rest
, andrights
. 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 usingMultiTargetNode
in those places. - BREAKING:
HashPatternNode#assocs
has been renamed toHashPatternNode#elements
.HashPatternNode#kwrest
has been renamed toHashPatternNode#rest
.
v0.15.1
v0.15.0
Added
BackReferenceReadNode#name
is now provided.Index{Operator,And,Or}WriteNode
are introduced, split out fromCall{Operator,And,Or}WriteNode
when the method is[]
.
Changed
- Ensure
PM_NODE_FLAG_COMMON_MASK
into a constant expression to fix compile errors. super(&arg)
is now fixed.- Ensure the last encoding flag on regular expressions wins.
- Fix the common whitespace calculation when embedded expressions begin on a line.
- Capture groups in regular expressions now scan the unescaped version to get the correct local variables.
*
and&
are added to the local table when...
is found in the parameters of a method definition.
v0.14.0
Added
- Syntax errors are added for invalid lambda local semicolon placement.
- Lambda locals are now checked for duplicate names.
- Destructured parameters are now checked for duplicate names.
Constant{Read,Path,PathTarget}Node#full_name
andConstant{Read,Path,PathTarget}Node#full_name_parts
are added to walk constant paths for you to find the full name of the constant.- Syntax errors are added when assigning to a numbered parameter.
Node::type
is added, which matches theNode#type
API.- Magic comments are now parsed as part of the parsing process and a new field is added in the form of
ParseResult#magic_comments
to access them.
Changed
- BREAKING:
Call*Node#name
methods now return symbols instead of strings. - BREAKING: For loops now have their index value considered as part of the body, so depths of local variable assignments will be increased by 1.
- Tilde heredocs now split up their lines into multiple string nodes to make them easier to dedent.
v0.13.0
Added
BEGIN {}
blocks are only allowed at the top-level, and will now provide a syntax error if they are not.- Numbered parameters are not allowed in block parameters, and will now provide a syntax error if they are.
- Many more Ruby modules and classes are now documented. Also, many have been moved into their own files and autoloaded so that initial boot time of the gem is much faster.
PM_TOKEN_METHOD_NAME
is introduced, used to indicate an identifier that if definitely a method name because it has an!
or?
at the end.- In the C API, arrays, assocs, and hashes now can have the
PM_NODE_FLAG_STATIC_LITERAL
flag attached if they can be compiled statically. This is used in CRuby, for example, to determine if aduphash
/duparray
instruction can be used as opposed to anewhash
/newarray
. Node#type
is introduced, which returns a symbol representing the type of the node. This is useful for case comparisons when you have to compare against multiple types.
Changed
- BREAKING: Everything has been renamed to
prism
instead ofyarp
. Theyp_
/YP_
prefix in the C API has been changed topm_
/PM_
. For the most part, everything should be find/replaceable. - BREAKING:
BlockArgumentNode
nodes now go into theblock
field onCallNode
nodes, in addition to theBlockNode
nodes that used to be there. Hopefully this makes it more consistent to compile/deal with in general, but it does mean it can be a surprising breaking change. - Escaped whitespace in
%w
lists is now properly unescaped. Node#pretty_print
now respects pretty print indentation.Dispatcher
was previously firing_leave
events in the incorrect order. This has now been fixed.- BREAKING:
Visitor
has now been split intoVisitor
andCompiler
. The visitor visits nodes but doesn't return anything from the visit methods. It is suitable for taking action based on the tree, but not manipulating the tree itself. TheCompiler
visits nodes and returns the computed value up the tree. It is suitable for compiling the tree into another format. As such,MutationVisitor
has been renamed toMutationCompiler
.
v0.12.0
Added
RegularExpressionNode#options
andInterpolatedRegularExpressionNode#options
are now provided. These return integers that match up to theRegexp#options
API.- Greatly improved
Node#inspect
andNode#pretty_print
APIs. MatchLastLineNode
andInterpolatedMatchLastLineNode
are introduced to represent using a regular expression as the predicate of anif
orunless
statement.IntegerNode
now has a base flag on it.- Heredocs that were previously
InterpolatedStringNode
andInterpolatedXStringNode
nodes without any actual interpolation are nowStringNode
andXStringNode
, respectively. StringNode
now has afrozen?
flag on it, which respects thefrozen_string_literal
magic comment.- Numbered parameters are now supported, and are properly represented using
LocalVariableReadNode
nodes. ImplicitNode
is introduced, which wraps implicit calls, local variable reads, or constant reads in omitted hash values.YARP::Dispatcher
is introduced, which provides a way for multiple objects to listen for certain events on the AST while it is being walked. This is effectively a way to implement a more efficient visitor pattern when you have many different uses for the AST.
Changed
- BREAKING: Flags fields are now marked as private, to ensure we can change their implementation under the hood. Actually querying should be through the accessor methods.
- BREAKING:
AliasNode
is now split intoAliasMethodNode
andAliasGlobalVariableNode
. - Method definitions on local variables is now correctly handled.
- Unary minus precedence has been fixed.
- Concatenating character literals with string literals is now fixed.
- Many more invalid syntaxes are now properly rejected.
- BREAKING: Comments now no longer include their trailing newline.