Commit graph

40 commits

Author SHA1 Message Date
Kevin Newton
052794bfe1 [ruby/prism] Accept a newline after the defined? keyword
[Bug #21197]

22be955ce9
2025-03-30 13:22:41 -04:00
Kevin Newton
3d6fc29169 [ruby/prism] Make xstrings concat syntax error
f734350499
2025-03-18 16:00:03 +00:00
Kevin Newton
2db365dc83 [ruby/prism] Fix escape unicode curly inline whitespace
Fixes [Bug #21145]

be2d845639
2025-02-17 18:12:03 +00:00
Kevin Newton
127325a4ba [ruby/prism] No writing to numbered parameters
Fixes [Bug #21117]

19d4bab5a0
2025-02-13 20:04:02 +00:00
Kevin Newton
b21e1aed2e [ruby/prism] Fix infinite loop in error recovery
When recovering from a depth error that occurs at the end of the
file, we need to break out of parsing statements.

Fixes [Bug #21114]

a32e268787
2025-02-13 19:12:10 +00:00
ydah
ca81142eff [ruby/prism] [Bug #21010] Reject endless method definition of []=
Fixes: https://bugs.ruby-lang.org/issues/20785

192960ce5d
2025-01-11 19:09:05 -05:00
Kevin Newton
96f23306f0 [ruby/prism] Revert "Reject pattern match with unexpected double splat inside array"
51e7c84124
2025-01-08 20:42:35 +00:00
ydah
500a87756f [ruby/prism] Reject pattern match with unexpected double splat inside array
`a => [-2**b]` should be SyntaxError

Fixes: https://github.com/ruby/prism/issues/3381

ae8e83b389
2025-01-08 17:23:51 +00:00
eileencodes
ad96c5a729 [ruby/prism] Throw syntax error for endless method with []=
Prism shoudld throw a syntax error for endless methods when the method
name uses brackets. Previously it would not. This matches the behavior
of parse.y.

Fixes https://bugs.ruby-lang.org/issues/21010

43c16a89ef
2025-01-07 19:35:01 +00:00
Junichi Ito
c8e3d745fa Use a single quote instead of a backtick for error messages
Fix https://bugs.ruby-lang.org/issues/20977
2025-01-05 20:50:53 -05:00
eileencodes
a21237571e [ruby/prism] Fix 3112 - disallow commas after block arg
Prism was already disallowing arguments after block args, but in
parse.y, any comma after a block arg is a syntax error. This moves the
error handling into `PM_TOKEN_UAMPERSAND` where we can check if the
current type is `PM_TOKEN_COMMA`then raise an error. I've also updated
the tests to include the examplesfrom ruby/prism#3112.

Fixes: ruby/prism#3112

754cf8eddc
2024-12-16 10:51:22 -05:00
Matt Valentine-House
b37777c36f [PRISM] Blocks are also a syntax error in array assignment
Actually close [Bug #20952]
2024-12-13 22:02:06 +00:00
Matt Valentine-House
e194665720 [PRISM] using []= to set kwargs is a syntax error
Fixes [Bug #20952]
2024-12-13 21:22:35 +00:00
Aaron Patterson
0a1fa99482 [ruby/prism] Same numbered param cannot be used in child blocks
Raise an exception when the same numbered param is used inside a child
block.  For example, the following code should be a syntax error:

```ruby
-> { _1 + -> { _1 } }
```

Fixes https://github.com/ruby/prism/pull/3291

d4fc441838
2024-12-12 00:42:27 +00:00
Aaron Patterson
6877c38866 [ruby/prism] Fix error messages for unterminated ( and {
If we hit an EOF token, and the character before the EOF is a newline,
we should make EOF token start at the previous newline.  That way any
errors reported will occur on that line.

For example "foo(\n" should report an error on line 1 even though the
EOF technically occurs on line 2.

[Bug #20918]
https://bugs.ruby-lang.org/issues/20918

60bc43de8e
2024-12-05 18:42:01 +00:00
ydah
fd217d475d [ruby/prism] Reject invalid operator after match predicate or after match required
Partially fixes: #3171

d0d9699c27
2024-12-02 18:42:16 +00:00
ydah
2ba5987263 [ruby/prism] Reject invalid dot method call after match predicate or after match required
Partially fixes:  https://github.com/ruby/prism/issues/3171

5c33fa5a1a
2024-12-02 18:41:38 +00:00
ydah
aa77bfd13e [ruby/prism] Reject extra comma in array after keyword argument
Fixes: https://github.com/ruby/prism/issues/3109

9ed989c30d
2024-12-02 18:39:49 +00:00
Haldun Bayhantopcu
6767117b07 [ruby/prism] Fix splat after kwsplat
70c1cd480f
2024-11-08 15:50:54 +00:00
Kevin Newton
21af248f92 [ruby/prism] Error for def ivar
232a02acef
2024-11-03 18:43:18 +00:00
Kevin Newton
82c76f1896 [ruby/prism] Reject invalid splat as last statement of parentheses
3a0b1c6110
2024-10-10 14:45:59 +00:00
Kevin Newton
4cbd2ab9d4 [ruby/prism] Properly handle non-assoc operators
dbd5c929d6
2024-10-07 17:57:36 +00:00
Kevin Newton
8d1906e8b7 [ruby/prism] Handle invalid commas in arguments, parameters, and arrays
023e894b74
2024-10-07 16:38:16 +00:00
Kevin Newton
75640037bf [ruby/prism] Fix up multi target parsing
80cd335222
2024-10-04 16:22:21 +00:00
Kevin Newton
f8568fbd7f [ruby/prism] Pop lex mode for heredocs in the lexer, not the parser
5dd36b979e
2024-10-03 17:30:20 +00:00
Kevin Newton
2610bf01b2 [ruby/prism] Fix up doubled range in arguments
aee2de91a3
2024-10-02 15:27:01 +00:00
Kevin Newton
467ebbebd9 [ruby/prism] Disallow dynamic patterns in labels at top level followed by pipes
ccc746f918
2024-10-01 15:42:44 -04:00
Kevin Newton
ec230ac643 Resync to latest Prism 2024-10-01 11:03:25 -04:00
Kevin Newton
75568d23e9 [ruby/prism] Disallow &. after endless range
498dd922d4
2024-10-01 12:57:00 +00:00
Kevin Newton
6c9b5c1615 Sync Prism with latest main branch 2024-09-30 11:36:29 -04:00
Kevin Newton
c1c9ba77ca [ruby/prism] Require a delimiter for singleton classes
fd58d6a9ea
2024-09-30 14:33:58 +00:00
Kevin Newton
1f431b63a2 [ruby/prism] Reject non-assoc ranges with subsequent operators
976a3cd0a5
2024-09-26 14:57:02 +00:00
Kevin Newton
be331c0eeb [ruby/prism] Fix up more error messages to more closely match parse.y
988ac82187
2024-09-25 19:19:18 +00:00
Kevin Newton
12cf9f2ae5 [ruby/prism] Fix up void value expression checking for rescue
509ff88e92
2024-09-25 18:34:51 +00:00
Kevin Newton
768ceceb12 [ruby/prism] Disallow label in parentheses
b624e09cc6
2024-09-25 17:33:51 +00:00
Kevin Newton
3eb42054d9 [ruby/prism] Pass Unicode escapes on to onigmo
When we encounter an invalid unicode escape within a regular
expression, we now pass that error on to Onigmo as if it didn't
exist in the parser (which matches the upstream parser's behavior).

We do this because there are tests that specify that you are
allowed to have invalid Unicode escapes if they are within the
context of a regular expression comment for a regular expression
in extended mode. That looks like:

    /# \u /x

Note that this _only_ applies to Unicode escapes (as opposed to
applying to hex or meta/control escapes as well). Importantly it
also only applies if the regular expression is terminated. An
unterminated regular expression will still get error handling done
in the parser. That would look like:

    /# \u

that would result in the same error handling we have today.

fb98034806
2024-08-23 19:18:14 +00:00
Kevin Newton
cbf508da58 [ruby/prism] Special error for too short unicode errors
9f1f7d08bd
2024-08-15 16:40:05 +00:00
Nobuyoshi Nakada
e642ddf7ae
[Bug #20647] Disallow return directly within a singleton class 2024-07-24 14:44:32 +09:00
Kevin Newton
ca48fb76fb [ruby/prism] Move location to second position for node initializers
4cc0eda4ca
2024-07-11 14:25:54 -04:00
Kevin Newton
678dd769e5 [ruby/prism] Reconfigure error tests
fb7e1ebb7f
2024-07-11 14:25:54 -04:00