summaryrefslogtreecommitdiff
path: root/prism/prism.c
AgeCommit message (Collapse)Author
2025-03-31[ruby/prism] Use `xmalloc()`/`xfree()`Alexander Momchilov
https://github.com/ruby/prism/commit/bd9027f0ab
2025-03-30[ruby/prism] Accept a newline after the defined? keywordKevin Newton
[Bug #21197] https://github.com/ruby/prism/commit/22be955ce9 Notes: Merged: https://github.com/ruby/ruby/pull/12999
2025-03-20[Bug #21026] no singleton method on pseudo variable literalNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12925
2025-03-18[ruby/prism] Add a multiple statements flag to parenthesesKevin Newton
This can get triggered even if the list of statements only contains a single statement. This is necessary to properly support compiling ```ruby defined? (;a) defined? (a;) ``` as "expression". Previously these were parsed as statements lists with single statements in them. https://github.com/ruby/prism/commit/b63b5d67a9
2025-03-18[ruby/prism] Track then keyword on rescue nodesKevin Newton
https://github.com/ruby/prism/commit/bde8ccc038
2025-03-18[ruby/prism] Make xstrings concat syntax errorKevin Newton
https://github.com/ruby/prism/commit/f734350499
2025-03-02[ruby/prism] Rename fgets parameter to fix NetBSDKevin Newton
Fixes [Bug #21165] https://github.com/ruby/prism/commit/3f0acf7560
2025-02-17[ruby/prism] Fix escape unicode curly inline whitespaceKevin Newton
Fixes [Bug #21145] https://github.com/ruby/prism/commit/be2d845639
2025-02-14[ruby/prism] Fix up it indirect writesKevin Newton
Fixes [Bug #21137] https://github.com/ruby/prism/commit/ca493e6797
2025-02-13[ruby/prism] No writing to numbered parametersKevin Newton
Fixes [Bug #21117] https://github.com/ruby/prism/commit/19d4bab5a0
2025-02-13[ruby/prism] Fix infinite loop in error recoveryKevin Newton
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] https://github.com/ruby/prism/commit/a32e268787
2025-02-13[ruby/prism] Split assertion per expressionsNobuyoshi Nakada
Expressions joined with `&&` are better asserted separately, so that it is clear from the failure message which expression is false. Also, `unsigned long` may not be enough for `ptrdiff_t`, e.g., Windows. Saying that `ptrdiff_t` can be larger than `SIZE_MAX` means that `PTRDIFF_MAX` is larger than `SIZE_MAX` and `ptrdiff_t` is sufficient to represent `SIZE_MAX`, otherwise if `PTRDIFF_MAX` is smaller than `SIZE_MAX`, `diff` will always be smaller than `SIZE_MAX` as well. `diff` could be equal to `SIZE_MAX` only if `PTRDIFF_MAX` is equal to `SIZE_MAX` and these assertions would pass, but I don't think there is any platform where that is the case. https://github.com/ruby/prism/commit/1fc6dfcada
2025-01-22[ruby/prism] Fix rescue modifier precedenceKevin Newton
Fixes [Bug #21048] https://github.com/ruby/prism/commit/07202005cb
2025-01-22[ruby/prism] Do not put empty statements in while because of -nKevin Newton
Fixes [Bug #21085] https://github.com/ruby/prism/commit/ebb9c36a10
2025-01-14[ruby/prism] Support forwarding flags on scopesKevin Newton
When parent scopes around an eval are forwarding parameters (like *, **, &, or ...) we need to know that information when we are in the parser. As such, we need to support passing that information into the scopes option. In order to do this, unfortunately we need a bunch of changes. The scopes option was previously an array of array of strings. These corresponded to the names of the locals in the parent scopes. We still support this, but now additionally support passing in a Prism::Scope instance at each index in the array. This Prism::Scope class holds both the names of the locals as well as an array of forwarding parameter names (symbols corresponding to the forwarding parameters). There is convenience function on the Prism module that creates a Prism::Scope object using Prism.scope. In JavaScript, we now additionally support an object much the same as the Ruby side. In Java, we now have a ParsingOptions.Scope class that holds that information. In the dump APIs, these objects in all 3 languages will add an additional byte for the forwarding flags in the middle of the scopes serialization. All of this is in service of properly parsing the following code: ```ruby def foo(*) = eval("bar(*)") ``` https://github.com/ruby/prism/commit/21abb6b7c4
2025-01-11[ruby/prism] Fix `not` receiverKevin Newton
`not foo` should be `!foo` `not()` should be `!nil` Fixes [Bug #21027] https://github.com/ruby/prism/commit/871ed4b462
2025-01-11[ruby/prism] Enable implicit fall-through errorsAlexander Momchilov
https://github.com/ruby/prism/commit/03797b84d3
2025-01-08[ruby/prism] Revert "Reject pattern match with unexpected double splat ↵Kevin Newton
inside array" https://github.com/ruby/prism/commit/51e7c84124
2025-01-08[ruby/prism] Handle escapes in named capture namesKevin Newton
https://github.com/ruby/prism/commit/b4b7a69ce7
2025-01-08[ruby/prism] Reject pattern match with unexpected double splat inside arrayydah
`a => [-2**b]` should be SyntaxError Fixes: https://github.com/ruby/prism/issues/3381 https://github.com/ruby/prism/commit/ae8e83b389
2025-01-07[ruby/prism] Throw syntax error for endless method with `[]=`eileencodes
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 https://github.com/ruby/prism/commit/43c16a89ef
2025-01-05[ruby/prism] Fix global variable read off endKevin Newton
https://github.com/ruby/prism/commit/3f2c34b53d
2024-12-29[Bug #20988] [prism] Fix escaped octal character literalsNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12487
2024-12-28[Bug #20990] Reject escaped multibyte char with control/meta prefixNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12485
2024-12-27[Bug #20986] [Prism] Allow escaped multibyte characterNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/12477
2024-12-26[ruby/prism] Handle escaped characters after controlsKevin Newton
Fixes [Bug #20986] https://github.com/ruby/prism/commit/fd0c563e9e
2024-12-16[ruby/prism] Update src/prism.cKevin Newton
https://github.com/ruby/prism/commit/544df5835f Notes: Merged: https://github.com/ruby/ruby/pull/12358
2024-12-16[ruby/prism] [Bug #20785] Allow `, and` and `, or` after patternsydah
Partially: https://bugs.ruby-lang.org/issues/20785 https://github.com/ruby/prism/commit/71c9102d02 Notes: Merged: https://github.com/ruby/ruby/pull/12358
2024-12-16[ruby/prism] Ignore newlines in labelled lambda argumentsHaldun Bayhantopcu
https://github.com/ruby/prism/commit/4ce6bcf182 Notes: Merged: https://github.com/ruby/ruby/pull/12358
2024-12-16[ruby/prism] Fix 3112 - disallow commas after block argeileencodes
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 https://github.com/ruby/prism/commit/754cf8eddc Notes: Merged: https://github.com/ruby/ruby/pull/12358
2024-12-16[ruby/prism] Add do keyword tracking for While/UntilKevin Newton
https://github.com/ruby/prism/commit/9686897290 Notes: Merged: https://github.com/ruby/ruby/pull/12358
2024-12-13[PRISM] Blocks are also a syntax error in array assignmentMatt Valentine-House
Actually close [Bug #20952] Notes: Merged: https://github.com/ruby/ruby/pull/12343
2024-12-13[PRISM] using []= to set kwargs is a syntax errorMatt Valentine-House
Fixes [Bug #20952] Notes: Merged: https://github.com/ruby/ruby/pull/12342
2024-12-12[ruby/prism] Use isinf on non-mingw windowsv3_4_0_rc1Kevin Newton
https://github.com/ruby/prism/commit/2f903d7865
2024-12-12[ruby/prism] Decode %r like % stringsAaron Patterson
%r regular expressions need to be decoded like strings. This commit fixes %r decoding so it works like strings. https://github.com/ruby/prism/commit/85bfd9c0cd
2024-12-12[ruby/prism] Same numbered param cannot be used in child blocksAaron Patterson
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 https://github.com/ruby/prism/commit/d4fc441838
2024-12-11[ruby/prism] Fix percent delimiter strings with crlfseileencodes
parse.y treats CRLF as a LF and basically "normalizes" them before parsing. That means a string like `%\nfoo\r\n` is actually treated as `%\nfoo\n` for the purposes of parsing. This happens on both the opening side of the percent string as well as on the closing side. So for example `%\r\nfoo\n` must be treated as `%\nfoo\n`. To handle this in Prism, when we start a % string, we check if it starts with `\r\n`, and then consider the terminator to actually be `\n`. Then we check if there are `\r\n` as we lex the string and treat those as `\n`, but only in the case the start was a `\n`. Fixes: #3230 [Bug #20938] https://github.com/ruby/prism/commit/e573ceaad6 Co-authored-by: John Hawthorn <[email protected]> Co-authored-by: eileencodes <[email protected]> Co-authored-by: Kevin Newton <[email protected]>
2024-12-05[ruby/prism] Fix error messages for unterminated ( and {Aaron Patterson
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 https://github.com/ruby/prism/commit/60bc43de8e
2024-12-02[ruby/prism] _finitef is unavailable on Windows x86Kevin Newton
Instead cast it inline to a double on Windows. https://github.com/ruby/prism/commit/9064d872aa
2024-12-02[ruby/prism] Reject invalid operator after match predicate or after match ↵ydah
required Partially fixes: #3171 https://github.com/ruby/prism/commit/d0d9699c27
2024-12-02[ruby/prism] Reject invalid dot method call after match predicate or after ↵ydah
match required Partially fixes: https://github.com/ruby/prism/issues/3171 https://github.com/ruby/prism/commit/5c33fa5a1a
2024-12-02[ruby/prism] Reject extra comma in array after keyword argumentydah
Fixes: https://github.com/ruby/prism/issues/3109 https://github.com/ruby/prism/commit/9ed989c30d
2024-11-28[ruby/prism] Fix a copy-paste errorYusuke Endoh
This is not important because of the path of `assert(false)`, but just in case. Coverity Scan found this issue. https://github.com/ruby/prism/commit/7335c62f9d
2024-11-08[ruby/prism] Fix splat after kwsplatHaldun Bayhantopcu
https://github.com/ruby/prism/commit/70c1cd480f
2024-11-03[ruby/prism] Error for def ivarKevin Newton
https://github.com/ruby/prism/commit/232a02acef
2024-10-11[ruby/prism] Prism::StringQueryKevin Newton
Introduce StringQuery to provide methods to access some metadata about the Ruby lexer. https://github.com/ruby/prism/commit/d3f55b67b9
2024-10-10[ruby/prism] Short-circuit if possible for start line and unused warningKevin Newton
https://github.com/ruby/prism/commit/2745c81d31
2024-10-10[ruby/prism] Do not warn for unused variables on negative linesKevin Newton
Fixes [Bug #20788] https://github.com/ruby/prism/commit/27e91f21af
2024-10-10[ruby/prism] Reject invalid splat as last statement of parenthesesKevin Newton
https://github.com/ruby/prism/commit/3a0b1c6110
2024-10-07[ruby/prism] Properly handle non-assoc operatorsKevin Newton
https://github.com/ruby/prism/commit/dbd5c929d6