summaryrefslogtreecommitdiff
path: root/test/prism/snapshots
AgeCommit message (Collapse)Author
2025-04-06Update prism test snapshots.nagachika
This is follow-up for 7c315e23983a35d29108d9ba8c914d6320254d43.
2023-12-16Revert all of commits after Prism 0.19.0 releaseHiroshi SHIBATA
We should bundle released version of Prism for Ruby 3.3.0
2023-12-15[ruby/prism] String literal hash keys should be frozeneileencodes
String literal hash keys can't be mutated by the user so we should mark them as frozen. We were seeing instructions for hashes with string literal keys using two `putstring` instructions when it should be a `putobject` and `putstring`. Code example: ```ruby { "a" => "b" } ``` Instructions before: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(2,14)> 0000 putobject "a" ( 2)[Li] 0002 putstring "b" 0004 newhash 2 0006 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,14)> 0000 putstring "a" ( 1)[Li] 0002 putstring "b" 0004 newhash 2 0006 leave ``` Instructions after: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(2,14)> 0000 putobject "a" ( 2)[Li] 0002 putstring "b" 0004 newhash 2 0006 leave "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,14)> 0000 putobject "a" ( 1)[Li] 0002 putstring "b" 0004 newhash 2 0006 leave ``` https://github.com/ruby/prism/commit/b14ae55385
2023-12-15[ruby/prism] Finish keyword hash node flag refactor by renaming flagUfuk Kayserilioglu
https://github.com/ruby/prism/commit/7f812389f8
2023-12-15[ruby/prism] Invalid pinned locals in pattern matchingKevin Newton
https://github.com/ruby/prism/commit/3a67b37a56
2023-12-14[ruby/prism] Fix parse result for nesting pattern matchingKevin Newton
https://github.com/ruby/prism/commit/ee6fc9ee87
2023-12-14[ruby/prism] Fix the implementation of the flag on keyword hash nodesUfuk Kayserilioglu
The previous implementation was incorrect since it was just checking for all keys in assoc nodes to be static literals but the actual check is that all keys in assoc nodes must be symbol nodes. This commit fixes that implementation, and, also, aliases the flag to `PM_KEYWORD_HASH_NODE_FLAGS_SYMBOL_KEYS` so that ruby/ruby can start using the new flag name. I intend to later change the real flag name to `PM_KEYWORD_HASH_NODE_FLAGS_SYMBOL_KEYS` and remove the alias. https://github.com/ruby/prism/commit/f5099c79ce
2023-12-14[ruby/prism] Fix hash pattern restKevin Newton
https://github.com/ruby/prism/commit/43c4232cfc
2023-12-12[ruby/prism] Flag for attribute write on callsKevin Newton
https://github.com/ruby/prism/commit/465731969c
2023-12-12[ruby/prism] Update tests and snapshotsUfuk Kayserilioglu
https://github.com/ruby/prism/commit/0663e2bcfa
2023-12-11[ruby/prism] Regexp terminator escapesKevin Newton
https://github.com/ruby/prism/commit/42a48a2ba9
2023-12-11[ruby/prism] Handle a non-interpolated dsym spanning a heredocKevin Newton
https://github.com/ruby/prism/commit/b23136ebfd
2023-12-11[ruby/prism] Split up CallNode in target positionKevin Newton
In this commit we're splitting up the call nodes that were in target positions (that is, for loop indices, rescue error captures, and multi assign targets). Previously, we would simply leave the call nodes in place. This had the benefit of keeping the AST relatively simple, but had the downside of not being very explicit. If a static analysis tool wanted to only look at call nodes, it could easily be confused because the method would have 1 fewer argument than it would actually be called with. This also brings some consistency to the AST. All of the nodes in a target position are now *TargetNode nodes. These should all be treated the same, and the call nodes can now be treated the same. Finally, there is benefit to memory. Because being in a target position ensures we don't have some fields, we can strip down the number of fields on these nodes. So this commit introduces two new nodes: CallTargetNode and IndexTargetNode. For CallTargetNode we get to drop the opening_loc, closing_loc, arguments, and block. Those can never be present. We also get to mark their fields as non-null, so they will always be seen as present. The IndexTargetNode keeps around most of its fields but gets to drop both the name (because it will always be []=) and the message_loc (which was always super confusing because it included the arguments by virtue of being inside the []). Overall, this adds complexity to the AST at the expense of memory savings and explicitness. I believe this tradeoff is worth it in this case, especially because these are very much not common nodes in the first place. https://github.com/ruby/prism/commit/3ef71cdb45
2023-12-11[ruby/prism] Fix to parse a (endless-)range with binary operatorsTSUYUSATO Kitsune
Fix https://github.com/ruby/prism/pull/2022 Fix https://github.com/ruby/prism/pull/2030 https://github.com/ruby/prism/commit/b78d8b6525
2023-12-08[ruby/prism] Add necessary encoding flags for symbols and regexKevin Newton
This doesn't actually fix the encodings for symbols and regex, unfortunately. But I wanted to get this change in because it is the last AST change we're going to make before 3.3 is released. So, if consumers want, they can start to check these flags to determine the encoding, even though it will be wrong. Then once we actually set them correctly, everything should work. https://github.com/ruby/prism/commit/9b35f7e891
2023-12-06[ruby/prism] Move flag position consistently to frontKevin Newton
https://github.com/ruby/prism/commit/6e69a81737
2023-12-06[ruby/prism] Provide flags for changing encodingsKevin Newton
https://github.com/ruby/prism/commit/e838eaff6f
2023-12-06[ruby/prism] Add locals_body_index to DefNode, BlockNode, LambdaNodeJemma Issroff
The locals_body_index gives the index in the locals array where the locals from the body start. This allows compilers to easily index past the parameters in the locals array. https://github.com/ruby/prism/commit/5d4627b890
2023-12-06[ruby/prism] Update snapshotHaldun Bayhantopcu
https://github.com/ruby/prism/commit/5f0ea09785
2023-12-05[ruby/prism] Fix defined with new lineeileencodes
It's possible to write the following and have it be valid Ruby: ``` defined?("foo" ) ``` But Prism wasn't taking the new line into account. This adds an `accept1` for a `PM_TOKEN_NEWLINE` to account for this. I've also updated the fixtures and snapshots to test this. https://github.com/ruby/prism/commit/b87f8eedc6
2023-12-05[ruby/prism] Add test casesTSUYUSATO Kitsune
https://github.com/ruby/prism/commit/e91f8dbb99
2023-12-05[ruby/prism] Fix some corner casesTSUYUSATO Kitsune
https://github.com/ruby/prism/commit/d5453f168e
2023-12-05[ruby/prism] Fix to parse command-style method calls more correctlyTSUYUSATO Kitsune
Fix https://github.com/ruby/prism/pull/1468 Fix https://github.com/ruby/prism/pull/1575 To decide command-style method calls are allowed, this introduce a new parameter `accepts_command_call` to `parse_expression` and some functions. Although one think this can be solved by operator precedence, it is hard or impossible, because the precedence of command-style calls is skewed (e.g. `! bar 1 ` is accepted, but `foo = ! bar 1` is rejected.) One of the most complex examples is that: (1) even though `foo = bar = baz 1` and `foo, bar = baz 1` is accepted, (2) `foo, bar = baz = fuzz 1` is rejected. To implement this behavior, this introduces a new binding power `PM_BINDING_POWER_MULTI_ASSIGNMENT` and uses it for distinguish which single assignments or multi assignments at their RHS. https://github.com/ruby/prism/commit/d4dd49ca81
2023-12-01[ruby/prism] Fix parsing heredoc endsHaldun Bayhantopcu
https://github.com/ruby/prism/commit/aa8c702271
2023-12-01[ruby/prism] Change numbered parametersKevin Newton
Previously numbered parameters were a field on blocks and lambdas that indicated the maximum number of numbered parameters in either the block or lambda, respectively. However they also had a parameters field that would always be nil in these cases. This changes it so that we introduce a NumberedParametersNode that goes in place of parameters, which has a single uint8_t maximum field on it. That field contains the maximum numbered parameter in either the block or lambda. As a part of the PR, I'm introducing a new UInt8Field type that can be used on nodes, which is just to make it a little more explicit what the maximum values can be (the maximum is actually 9, since it only goes up to _9). Plus we can do a couple of nice things in serialization like just read a single byte. https://github.com/ruby/prism/commit/2d87303903
2023-12-01[ruby/prism] Update snapshotsKevin Newton
https://github.com/ruby/prism/commit/f4c80c67dc
2023-12-01[PRISM] Remove transparent scope nodesMatt Valentine-House
2023-12-01[ruby/prism] Add test/prism/snapshots/heredoc_with_comment.txtHiroshi SHIBATA
https://github.com/ruby/prism/commit/97b296a0f7
2023-11-30[ruby/prism] Fix lex_compat for `<<HEREDOC # comment` at EOFMartin Emde
Fixes https://github.com/ruby/prism/pull/1874 https://github.com/ruby/prism/commit/304dd78dd2
2023-11-29[ruby/prism] Reject class/module defs in method params/rescue/ensure/elseTSUYUSATO Kitsune
Fix https://github.com/ruby/prism/pull/1936 https://github.com/ruby/prism/commit/232e77a003
2023-11-28[ruby/prism] Implicit rest nodesKevin Newton
Fundamentally, `foo { |bar,| }` is different from `foo { |bar, *| }` because of arity checks. This PR introduces a new node to handle that, `ImplicitRestNode`, which goes in the `rest` slot of parameter nodes instead of `RestParameterNode` instances. This is also used in a couple of other places, namely: * pattern matching: `foo in [bar,]` * multi target: `for foo, in bar do end` * multi write: `foo, = bar` Now the only splat nodes with a `NULL` value are when you're forwarding, as in: `def foo(*) = bar(*)`. https://github.com/ruby/prism/commit/dba2a3b652
2023-11-28[ruby/prism] Add numbered_parameters field to BlockNode and LambdaNodeJemma Issroff
We are aware at parse time how many numbered parameters we have on a BlockNode or LambdaNode, but prior to this commit, did not store that information anywhere in its own right. The numbered parameters were stored as locals, but this does not distinguish them from other locals that have been set, for example in `a { b = 1; _1 }` there is nothing on the AST that distinguishes b from _1. Consumers such as the compiler need to know information about how many numbered parameters exist to set up their own tables around parameters. Since we have this information at parse time, we should compute it here, instead of deferring the work later on. https://github.com/ruby/prism/commit/bf4a1e124d
2023-11-28[ruby/prism] Reset `current_param_name` around closed scopesTSUYUSATO Kitsune
It is for supporting `def foo(bar = (def baz(bar) = bar; 1)) = 2` case. https://github.com/ruby/prism/commit/c789a833c5
2023-11-28[ruby/prism] Fix to parse `*` as forwarding in `foo[*]` caseTSUYUSATO Kitsune
Fix https://github.com/ruby/prism/pull/1924 https://github.com/ruby/prism/commit/7cde900065
2023-11-27[ruby/prism] Fix and reuse pm_call_node_index_pTSUYUSATO Kitsune
Fix https://github.com/ruby/prism/pull/1925 Fix https://github.com/ruby/prism/pull/1927 Previously pm_call_node_index_p does not check about a block argument correctly and is not used in parse_write to check an index call node. This commit fixes these problems. https://github.com/ruby/prism/commit/92bab044ff
2023-11-23[ruby/prism] Fix LocalVariableTargetNode depth in patternsTSUYUSATO Kitsune
Fix https://github.com/ruby/prism/pull/1821 https://github.com/ruby/prism/commit/7d023a26b4
2023-11-22[ruby/prism] Fix associativity of binary range with begin-less rangeTSUYUSATO Kitsune
Fix https://github.com/ruby/prism/pull/1828 https://github.com/ruby/prism/commit/22c0640e48
2023-11-22[ruby/prism] Add and use pm_parser_local_depth_constant_idTSUYUSATO Kitsune
https://github.com/ruby/prism/pull/1877#discussion_r1398974248 https://github.com/ruby/prism/commit/0f545fe636
2023-11-22[ruby/prism] Allow `&` forwarding in a method having `...` parameterTSUYUSATO Kitsune
Fix https://github.com/ruby/prism/pull/1839 https://github.com/ruby/prism/commit/5784ab749f
2023-11-22[ruby/prism] Move CallNode#name field between receiver and argumentsBenoit Daloze
* The same order as in source code. * CallOrWriteNode, CallOperatorWriteNode, CallAndWriteNode already have the correct order so it was also inconsistent with them. https://github.com/ruby/prism/commit/4434e4bc22
2023-11-21[ruby/prism] Add SPLAT flag on ArrayNode indicating if it contains splat ↵Jemma Issroff
element(s) This commit puts a SPLAT flag on any ArrayNodes which contain SplatNode elements https://github.com/ruby/prism/commit/2fc1e7f181
2023-11-21[PRISM] Rename flag to CONTAINS_KEYWORD_SPLATJemma Issroff
We need to do this change first on ruby/ruby before merging to ruby/prism to avoid breaking ruby/ruby CI
2023-11-21[ruby/prism] Fix lex_state_beg_pHaldun Bayhantopcu
(https://github.com/ruby/prism/pull/1591) https://github.com/ruby/prism/commit/46b8576dd0
2023-11-21[ruby/prism] Remove string concat in favor of a flat listKevin Newton
Right now when you have a lot of string concats it ends up being difficult to work with because of the depth of the tree. You end up descending very far for every string literal that is part of the concat. There are already times when we use an interpolated string node to group together two string segments that are part of the same string (like when they are interupted by the contents of a heredoc). This commit takes the same approach and replaces string concats with interpolated string nodes. Now that they're a flat list, they should be much easier to work with. There's still some missing information here that would be useful to consumers: whether or not there is _actually_ any interpolation contained in the list. We could remedy this with another node type that is named something like string list, or we could add a flag to interpolated string node indicating that there is interpolation. Either way I want to solve that in a follow-up commit, since this commit is valuable on its own. https://github.com/ruby/prism/commit/1e7ae3ad1b
2023-11-21[ruby/prism] Split up CaseNode and CaseMatchNodeKevin Newton
(https://github.com/ruby/prism/pull/1801) https://github.com/ruby/prism/commit/4c1391ea56
2023-11-20[ruby/prism] Fix locations derived from arguments.Haldun Bayhantopcu
(https://github.com/ruby/prism/pull/1897) https://github.com/ruby/prism/commit/00b76ef254
2023-11-20[ruby/prism] Replace match write locals with match write targetsKevin Newton
https://github.com/ruby/prism/commit/eec1862967
2023-11-20[ruby/prism] Correctly parse the `resuce` modifier in the rhs of theHiroya Fujinami
assignments (https://github.com/ruby/prism/pull/1879) Fix https://github.com/ruby/prism/pull/1541 https://github.com/ruby/prism/commit/9fb276e1f4
2023-11-19[ruby/prism] Don't add an invalid identifier capture to localsHiroya Fujinami
(https://github.com/ruby/prism/pull/1836) * Don't add an invalid identifier capture to locals Fix https://github.com/ruby/prism/pull/1815 * Delay creating a MatchWriteNode https://github.com/ruby/prism/pull/1836#discussion_r1393716600 https://github.com/ruby/prism/commit/635f595a36
2023-11-16[ruby/prism] Fix calls with splat without parenthesisHaldun Bayhantopcu
https://github.com/ruby/prism/commit/d81a77e0e3