Nobuyoshi Nakada
69823b97b5
[Bug #20423 ] Fix error message of prism
2024-04-12 17:02:46 +09:00
Nobuyoshi Nakada
e36988450e
[Bug #20423 ] Disallow anonymous block within argument forwarding
2024-04-12 16:07:49 +09:00
Kevin Newton
56f9ac8d31
[ruby/prism] More unreachables
...
https://github.com/ruby/prism/commit/735f3122c2
2024-04-11 12:12:34 +00:00
Kevin Newton
77d3996897
[ruby/prism] Put in an unreachable assert for rescues parsing
...
https://github.com/ruby/prism/commit/7a60b61368
2024-04-10 19:45:13 +00:00
Kevin Newton
0107954f25
[ruby/prism] Fix up invalid global variable error message
...
https://github.com/ruby/prism/commit/8ce9ae487f
2024-04-09 16:29:01 +00:00
Kevin Newton
d101ec65e9
[ruby/prism] Reduce locals variables per CRuby
...
https://github.com/ruby/prism/commit/3e6830c3a5
2024-04-09 15:55:57 +00:00
Kevin Newton
f2ac26d914
[ruby/prism] Bump to v0.25.0
...
https://github.com/ruby/prism/commit/4da514456f
2024-04-05 21:44:06 +00:00
Kevin Newton
fbeb8f2c78
[ruby/prism] Set up location correctly for hashed locals
...
https://github.com/ruby/prism/commit/0334140790
2024-04-05 19:24:04 +00:00
Kevin Newton
1953ead74e
[ruby/prism] Use a simpler and faster hash function for locals
...
https://github.com/ruby/prism/commit/5f56bf4464
2024-04-05 19:24:04 +00:00
Kevin Newton
a801889c58
[ruby/prism] Do not warn for locals that start with _
...
https://github.com/ruby/prism/commit/8b8d66e55d
2024-04-05 19:24:03 +00:00
Kevin Newton
37ba6927d1
[ruby/prism] Always calloc the locals resize
...
https://github.com/ruby/prism/commit/8bbd3fef6f
2024-04-05 19:24:03 +00:00
Kevin Newton
3b59addaf1
[ruby/prism] Provide documentation for the new local tables
...
https://github.com/ruby/prism/commit/7a47a1351f
2024-04-05 19:24:01 +00:00
Kevin Newton
413a151a6b
[ruby/prism] Explicitly cast from uint64_t to double for mid-square hash
...
https://github.com/ruby/prism/commit/06c6501044
2024-04-05 19:24:01 +00:00
Kevin Newton
5e93cf9250
[ruby/prism] Optimize pm_locals_order
...
https://github.com/ruby/prism/commit/13fe4e03c7
2024-04-05 19:24:01 +00:00
Kevin Newton
3638aeb4cb
[ruby/prism] Refactor around pm_parser_scope_find
...
https://github.com/ruby/prism/commit/79d83eb95e
2024-04-05 19:24:00 +00:00
Kevin Newton
dcec1e0dc6
[ruby/prism] Replace old circular parameter definition detection
...
https://github.com/ruby/prism/commit/c739f8e194
2024-04-05 19:24:00 +00:00
Kevin Newton
bf3a911d1b
[ruby/prism] Do not warn on unused parameters
...
https://github.com/ruby/prism/commit/c8d222640a
2024-04-05 19:23:59 +00:00
Kevin Newton
b5b4628991
[ruby/prism] Warn on unused local variables
...
https://github.com/ruby/prism/commit/de111935fb
2024-04-05 19:23:59 +00:00
Kevin Newton
e6aeacb099
[ruby/prism] Lazily hash locals
...
https://github.com/ruby/prism/commit/ef8ea4624a
2024-04-05 19:23:58 +00:00
Kevin Newton
f9c05a65c9
[ruby/prism] Track the number of reads for local variables
...
https://github.com/ruby/prism/commit/dce64f4640
2024-04-05 19:23:58 +00:00
Kevin Newton
540cc886b9
[ruby/prism] Make the locals set switch from list to hash dynamically
...
https://github.com/ruby/prism/commit/c977c4c98a
2024-04-05 19:23:57 +00:00
Kevin Newton
358aeb103b
[ruby/prism] Switch locals to use a hash
...
https://github.com/ruby/prism/commit/f38946021e
2024-04-05 19:23:57 +00:00
Kevin Newton
440c63df31
[ruby/prism] Change forwarding error messages to match CRuby
...
https://github.com/ruby/prism/commit/6a15e475c9
2024-04-04 20:59:08 +00:00
Kevin Newton
6bbb3e31fb
[ruby/prism] Allow retry in rescue modifier
...
https://github.com/ruby/prism/commit/debe19459a
2024-04-03 17:34:12 -04:00
Kevin Newton
e48fd40974
[ruby/prism] No invalid block exits in eval
...
https://github.com/ruby/prism/commit/85e045ce40
2024-04-03 17:34:12 -04:00
Kevin Newton
a64f1ab688
[ruby/prism] Fix up pm_node_list_grow
...
https://github.com/ruby/prism/commit/7784365d3f
2024-04-03 17:34:12 -04:00
Kevin Newton
a33f19f783
[ruby/prism] Allow yields in default values in method definitions
...
https://github.com/ruby/prism/commit/5bc4cc3413
2024-04-03 17:34:12 -04:00
Kevin Newton
bddd004ce9
[ruby/prism] Further delineate block types
...
https://github.com/ruby/prism/commit/750116e5dc
2024-04-03 17:34:12 -04:00
Kevin Newton
e19fccbfdb
[ruby/prism] Delineate rescue/else/ensure for more accurate exits
...
https://github.com/ruby/prism/commit/92868fad78
2024-04-03 17:34:12 -04:00
Kevin Newton
be48b733b6
[ruby/prism] Pass block exits up the tree
...
https://github.com/ruby/prism/commit/168f72b9fe
2024-04-03 17:34:12 -04:00
Kevin Newton
1fb11824f3
[ruby/prism] Introduce PM_NODE_LIST_FOREACH to make it easier to iterate over node lists
...
https://github.com/ruby/prism/commit/5d4da7c69c
2024-04-03 17:34:12 -04:00
Kevin Newton
198d197aeb
[ruby/prism] Allow block exits in defined? and fix modifier while/until
...
https://github.com/ruby/prism/commit/2752f0b8df
2024-04-03 17:34:12 -04:00
Kevin Newton
7ddf093588
[ruby/prism] Allow block exits from while/until/for
...
https://github.com/ruby/prism/commit/bc46306b9b
2024-04-03 17:34:12 -04:00
Kevin Newton
e454cf2202
[ruby/prism] Update fixtures to be all valid Ruby
...
https://github.com/ruby/prism/commit/a0b978d25b
2024-04-03 17:34:12 -04:00
Kevin Newton
7d9e5061aa
[ruby/prism] Correct errors for invalid retry
...
https://github.com/ruby/prism/commit/96ca6e51fc
2024-04-03 17:34:12 -04:00
Kevin Newton
a83736c27d
[ruby/prism] Log errors for invalid jumps
...
https://github.com/ruby/prism/commit/892d0f9310
2024-04-03 17:34:12 -04:00
Kevin Newton
08c841ff63
[ruby/prism] Use tilde for extended error lines
...
https://github.com/ruby/prism/commit/daaa386a4f
2024-04-03 17:34:12 -04:00
Kevin Newton
3147404d64
[ruby/prism] Match circular parameter error message
...
https://github.com/ruby/prism/commit/c0381b10e4
2024-04-03 17:34:12 -04:00
Kevin Newton
b25282e618
[ruby/prism] Replace . with decimal point for strtod
...
https://github.com/ruby/prism/commit/578a4f983e
2024-04-01 19:39:33 +00:00
Kevin Newton
d6c1cc5532
[ruby/prism] Fix up error messages for empty global variable
...
https://github.com/ruby/prism/commit/fa7559d40b
2024-04-01 19:28:05 +00:00
Kevin Newton
d898f00fe1
[ruby/prism] Match error messages for invalid instance/class variables
...
https://github.com/ruby/prism/commit/82fd0599ed
2024-04-01 19:28:05 +00:00
Kevin Newton
67bd5b33f9
[ruby/prism] Match error message for invalid class/module name
...
https://github.com/ruby/prism/commit/f00ae59070
2024-04-01 19:28:04 +00:00
Kevin Newton
05904c3b72
[ruby/prism] Match error message for invalid class/module definition
...
https://github.com/ruby/prism/commit/1879a9d22e
2024-04-01 19:28:04 +00:00
Kevin Newton
a885d597d5
[ruby/prism] Match error message for multiple blocks given
...
https://github.com/ruby/prism/commit/6b594d9d42
2024-04-01 19:28:04 +00:00
Kevin Newton
fee70c1ed7
[ruby/prism] Add better error messages for invalid block-locals
...
https://github.com/ruby/prism/commit/27ad452436
2024-04-01 19:28:03 +00:00
Kevin Newton
1e737ec977
[ruby/prism] Fix up error message for invalid numbered reference alias
...
https://github.com/ruby/prism/commit/74bff9e834
2024-04-01 19:28:03 +00:00
Kevin Newton
a9658b6409
[ruby/prism] Do not track locals starting with _
...
https://github.com/ruby/prism/commit/0d5a6d936a
2024-04-01 18:13:45 +00:00
Kevin Newton
c2735c48a1
[ruby/prism] Track duplicate hash keys for pattern matching
...
https://github.com/ruby/prism/commit/71ea82f299
2024-04-01 18:13:45 +00:00
Kevin Newton
f1e385aad9
[ruby/prism] Track captures in pattern matching for duplicates
...
https://github.com/ruby/prism/commit/aa2182f064
2024-04-01 18:13:44 +00:00
Kevin Newton
cdb8d208c9
[PRISM] Fix error message for duplicate parameter name
2024-03-29 19:32:23 -04:00
Kevin Newton
729a39685b
[ruby/prism] Fix calloc argument order
...
https://github.com/ruby/prism/commit/9947ab13c0
2024-03-29 15:44:02 +00:00
Kevin Newton
718c7d4a37
[ruby/prism] Handle NULL byte terminators for strings, regexps, and lists
...
https://github.com/ruby/prism/commit/79a75258a4
2024-03-29 15:43:55 +00:00
Kevin Newton
a8ec347ca2
[ruby/prism] Allow writing to keywords with named captures if they are already locals
...
https://github.com/ruby/prism/commit/418318e1c8
2024-03-28 20:39:03 +00:00
Kevin Newton
8780059c38
[ruby/prism] Reject invalid capture groups (keywords)
...
https://github.com/ruby/prism/commit/bb78d83e88
2024-03-28 19:30:38 +00:00
Kevin Newton
3e9c684236
[PRISM] Allow space before encoding comment
2024-03-28 13:02:06 -04:00
Kevin Newton
86e0d83a32
[PRISM] Simplify raising load errors
2024-03-28 12:04:35 -04:00
Kevin Newton
d583616f32
[ruby/prism] Ensure deserialization works with errors+warnings>256
...
https://github.com/ruby/prism/commit/f540e830b5
2024-03-28 12:04:35 -04:00
Kevin Newton
35ff302893
[ruby/prism] Various cleanup with new -x option
...
https://github.com/ruby/prism/commit/020756fb11
2024-03-28 12:04:35 -04:00
Kevin Newton
fcc06fa82a
[ruby/prism] CLI -x flag
...
https://github.com/ruby/prism/commit/2068e3c30a
2024-03-28 12:04:35 -04:00
Andrew Konchin
7055dcf915
[ruby/prism] Improve description for InterpolatedStringNodeFlags
...
https://github.com/ruby/prism/commit/caa576d63f
2024-03-28 14:48:20 +00:00
Kevin Newton
9b97f1f3e8
[ruby/prism] Compare duplicates keys/whens for __FILE__
...
https://github.com/ruby/prism/commit/85263ade63
2024-03-27 18:57:35 +00:00
Kevin Newton
4361727d28
[ruby/prism] Warn on static literal arrays in predicate writes
...
https://github.com/ruby/prism/commit/faadd05693
2024-03-27 18:28:58 +00:00
Kevin Newton
39606f36e3
[PRISM] Implicitly change encoding when a UTF-8 BOM is found
2024-03-27 14:19:58 -04:00
Kevin Newton
eb995a6410
[PRISM] Include file and line in error message
2024-03-27 14:19:58 -04:00
Kevin Newton
9b816e674a
[ruby/prism] Add option for inlining messages for error formatting
...
https://github.com/ruby/prism/commit/af0204a8ab
2024-03-27 13:03:11 -04:00
Kevin Newton
2505c27fdf
[PRISM] Fix up some error formatting edge cases
2024-03-27 08:48:32 -04:00
Koichi ITO
4a78d75213
[ruby/prism] Fix an incorrect range of `Prism::Location` when `PM_ERR_RETURN_INVALID`
...
This PR fixes the following incorrect range of `Prism::Location` when `PM_ERR_RETURN_INVALID`.
It may be hard to tell from the text, but this Ruby error highlights `return`:
```console
$ ruby -e 'class Foo return end'
-e:1: Invalid return in class/module body
class Foo return end
-e: compile error (SyntaxError)
```
Previously, the error's `Prism::Location` pointed to `end`:
```console
$ bundle exec ruby -Ilib -rprism -ve 'p Prism.parse("class Foo return end").errors'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75
) [x86_64-darwin22]
[#<Prism::ParseError @type=:return_invalid @message="invalid `return` in a class or module body"
@location=#<Prism::Location @start_offset=17 @length=3 start_line=1> @level=:fatal>]
After this fix, it will indicate `return`.
```console
$ bundle exec ruby -Ilib -rprism -ve 'p Prism.parse("class Foo return end").errors'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75
) [x86_64-darwin22]
[#<Prism::ParseError @type=:return_invalid @message="invalid `return` in a class or module body"
@location=#<Prism::Location @start_offset=10 @length=6 start_line=1> @level=:fatal>]
```
For reference, here are the before and after of `Prism::Translation::Parser`.
Before:
```console
$ bundle exec ruby -Ilib -rprism -rprism/translation/parser33 -ve 'p Prism::Translation::Parser33.parse("class Foo return end")'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75
) [x86_64-darwin22]
(string):1:18: error: invalid `return` in a class or module body
(string):1: class Foo return end
(string):1: ^~~
/Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-3.3.0.5/lib/parser/diagnostic/engine.rb:72:in `process':
invalid `return` in a class or module body (Parser::SyntaxError)
from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:220:in `block in unwrap'
from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:218:in `each'
from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:218:in `unwrap'
from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:49:in `parse'
from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-3.3.0.5/lib/parser/base.rb:33:in `parse'
from -e:1:in `<main>'
```
After:
```console
$ bundle exec ruby -Ilib -rprism -rprism/translation/parser33 -ve 'p Prism::Translation::Parser33.parse("class Foo return end")'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75
) [x86_64-darwin22]
(string):1:11: error: invalid `return` in a class or module body
(string):1: class Foo return end
(string):1: ^~~~~~
/Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-3.3.0.5/lib/parser/diagnostic/engine.rb:72:in `process':
invalid `return` in a class or module body (Parser::SyntaxError)
from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:220:in `block in unwrap'
from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:218:in `each'
from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:218:in `unwrap'
from /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser.rb:49:in `parse'
from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-3.3.0.5/lib/parser/base.rb:33:in `parse'
from -e:1:in `<main>'
```
This PR ensures that the originally intended `return` is highlighted as it should be.
https://github.com/ruby/prism/commit/1f9af4d2ad
2024-03-26 14:41:27 -04:00
Kevin Newton
8ec7c3ce30
[ruby/prism] Properly handle freeing ephemeral node lists
...
https://github.com/ruby/prism/commit/f49261a9b9
2024-03-26 12:11:09 -04:00
Kevin Newton
2a3601d64e
[ruby/prism] Handle regexp split between heredocs
...
https://github.com/ruby/prism/commit/c1400d8aed
2024-03-26 12:11:09 -04:00
Kevin Newton
240fb3957b
[ruby/prism] Freeze internal parts, again
...
https://github.com/ruby/prism/commit/50372fee5c
2024-03-26 12:11:09 -04:00
Koichi ITO
52cf6ec46b
[ruby/prism] Fix typos
...
After finding the "if if" typo, some additional typos identified by running `codespell` are also being corrected:
https://github.com/codespell-project/codespell
https://github.com/ruby/prism/commit/e6a34cfeeb
2024-03-26 10:51:12 +00:00
Kevin Newton
453de8c2bc
[ruby/prism] Revert "Frozen parts"
...
https://github.com/ruby/prism/commit/48f2e8c169
2024-03-25 19:08:46 +00:00
Kevin Newton
ff8f98f5c2
[ruby/prism] Mark interpolated nodes as static literal
...
https://github.com/ruby/prism/commit/d00977a9bd
2024-03-25 17:36:13 +00:00
Kevin Newton
eef272f154
[ruby/prism] Mark inner parts of interpolated* nodes as frozen
...
https://github.com/ruby/prism/commit/58a127cd5d
2024-03-25 17:36:12 +00:00
Kevin Newton
a08954569f
[ruby/prism] Fix up minimal build setting
...
https://github.com/ruby/prism/commit/98c85c4acb
2024-03-25 11:54:20 -04:00
Kevin Newton
53cc272387
[ruby/prism] Handle CLRF in regexp
...
https://github.com/ruby/prism/commit/b96bada9ae
2024-03-25 11:52:13 -04:00
Kevin Newton
86077fbcde
[ruby/prism] Refactor regexp lexing to make it easier to support CLRF
...
https://github.com/ruby/prism/commit/60805d85ca
2024-03-25 11:52:12 -04:00
Kevin Newton
0bc764b729
[ruby/prism] Handle CLRF inside string contents
...
https://github.com/ruby/prism/commit/aac606301e
2024-03-25 11:52:10 -04:00
Kevin Newton
14ab698967
[ruby/prism] Handle CLRF inside heredoc contents
...
https://github.com/ruby/prism/commit/1fbac72485
2024-03-25 11:52:09 -04:00
Koichi ITO
65264b0dfb
[ruby/prism] Fix build error for C99 and C23 CI matrix
...
This PR fixes the following build error for C99 and C23 Ruby's CI matrix:
```console
../src/prism/prism.c:1241:19: error: initializing 'char *' with an expression of
type 'const char *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
1241 | char *word = unknown_flags_length >= 2 ? "options" : "option";
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
assembling ../src/coroutine/amd64/Context.S
```
- c99 ... https://github.com/ruby/ruby/actions/runs/8419905079/job/23053543994#step:10:249
- c23 ... https://github.com/ruby/ruby/actions/runs/8419905079/job/23053544274#step:10:257
This is an incorrect code introduced in https://github.com/ruby/prism/pull/2618 .
https://github.com/ruby/prism/commit/4d9d73fcb9
2024-03-25 14:11:07 +00:00
Franck Trouillez
54428c2bf1
[ruby/prism] Add missing symbol in comment for binding powers for `||=`
...
This adds in the descriptive comment the `||=` operator corresponding to `PM_TOKEN_PIPE_PIPE_EQUAL` for pm_binding_powers[PM_TOKEN_MAXIMUM] in prism.c
https://github.com/ruby/prism/commit/315ca16e23
2024-03-25 12:16:46 +00:00
Franck Trouillez
d05135727f
[ruby/prism] Fix comment typos in prism.c
...
This fixes some comment typos in English in the prism.c file. It fixes some typos and follows the current conventions:
- Sentences in comments end with `.`
- Use infinitive instead of 3rd person present simple to describe functions
https://github.com/ruby/prism/commit/01324e89db
2024-03-25 12:16:45 +00:00
Koichi ITO
56a2fad2a4
[ruby/prism] Fix incorrect paring when using invalid regexp options
...
Fixes https://github.com/ruby/prism/pull/2617 .
There was an issue with the lexer as follows.
The following are valid regexp options:
```console
$ bundle exec ruby -Ilib -rprism -ve 'p Prism.lex("/x/io").value.map {|token| token[0].type }'
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75 ) [x86_64-darwin22]
[:REGEXP_BEGIN, :STRING_CONTENT, :REGEXP_END, :EOF]
```
The following are invalid regexp options. Unnecessary the `IDENTIFIER` token is appearing:
```console
$ bundle exec ruby -Ilib -rprism -ve 'p Prism.lex("/x/az").value.map {|token| token[0].type }'
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75 ) [x86_64-darwin22]
[:REGEXP_BEGIN, :STRING_CONTENT, :REGEXP_END, :IDENTIFIER, :EOF]
```
As a behavior of Ruby, when given `A` to `Z` and `a` to `z`, they act as invalid regexp options. e.g.,
```console
$ ruby -e '/regexp/az'
-e:1: unknown regexp options - az
/regexp/az
-e: compile error (SyntaxError)
```
Thus, it should probably not be construed as `IDENTIFIER` token.
Therefore, `pm_byte_table` has been adapted to accept those invalid regexp option values.
Whether it is a valid regexp option or not is checked by `pm_regular_expression_flags_create`.
For invalid regexp options, `PM_ERR_REGEXP_UNKNOWN_OPTIONS` is added to diagnostics.
https://github.com/ruby/prism/commit/d2a6096fcf
2024-03-25 12:16:32 +00:00
Kevin Newton
af7bf9e0d8
[ruby/prism] Provide options for reducing size
...
https://github.com/ruby/prism/commit/592128de4d
2024-03-20 17:32:03 -04:00
Koichi ITO
0a10702747
[ruby/prism] Fix a diagnostic incompatibility
...
This PR fixes a diagnostic incompatibility when using no anonymous keyword rest parameter:
```ruby
foo(**)
```
Note, although the actual update applies only to the `foo(**)` case, for reference,
`foo(*)` and `foo(&) are also mentioned below.
## Ruby (Expected)
```console
$ ruby -cve 'foo(*)'
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75 ) [x86_64-darwin22]
-e:1: no anonymous rest parameter
-e: compile error (SyntaxError)
$ ruby -cve 'foo(**)'
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75 ) [x86_64-darwin22]
-e:1: no anonymous keyword rest parameter
-e: compile error (SyntaxError)
$ ruby -cve 'foo(&)'
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75 ) [x86_64-darwin22]
-e:1: no anonymous block parameter
-e: compile error (SyntaxError)
```
## Prism (Actual)
Before:
```console
$ bundle exec ruby -Ilib -rprism -wve 'p Prism.parse("foo(*)").errors'
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75 ) [x86_64-darwin22]
[#<Prism::ParseError @type=:argument_no_forwarding_star @message="unexpected `*` when the parent method is not forwarding"
@location=#<Prism::Location @start_offset=4 @length=1 start_line=1> @level=:fatal>]
$ bundle exec ruby -Ilib -rprism -wve 'p Prism.parse("foo(**)").errors'
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75 ) [x86_64-darwin22]
[#<Prism::ParseError @type=:expect_expression_after_splat_hash @message="expected an expression after `**` in a hash"
@location=#<Prism::Location @start_offset=4 @length=2 start_line=1> @level=:fatal>]
$ bundle exec ruby -Ilib -rprism -wve 'p Prism.parse("foo(&)").errors'
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75 ) [x86_64-darwin22]
[#<Prism::ParseError @type=:argument_no_forwarding_amp @message="unexpected `&` when the parent method is not forwarding"
@location=#<Prism::Location @start_offset=4 @length=1 start_line=1> @level=:fatal>]
```
After:
```console
$ bundle exec ruby -Ilib -rprism -wve 'p Prism.parse("foo(*)").errors'
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75 ) [x86_64-darwin22]
[#<Prism::ParseError @type=:argument_no_forwarding_star @message="unexpected `*` when the parent method is not forwarding"
@location=#<Prism::Location @start_offset=4 @length=1 start_line=1> @level=:fatal>]
$ bundle exec ruby -Ilib -rprism -wve 'p Prism.parse("foo(**)").errors'
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75 ) [x86_64-darwin22]
[#<Prism::ParseError @type=:argument_no_forwarding_star_star @message="unexpected `**` when the parent method is not forwarding"
@location=#<Prism::Location @start_offset=4 @length=2 start_line=1> @level=:fatal>]
$ bundle exec ruby -Ilib -rprism -wve 'p Prism.parse("foo(&)").errors'
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75 ) [x86_64-darwin22]
[#<Prism::ParseError @type=:argument_no_forwarding_amp @message="unexpected `&` when the parent method is not forwarding"
@location=#<Prism::Location @start_offset=4 @length=1 start_line=1> @level=:fatal>]
```
https://github.com/ruby/prism/commit/633c9d9fd4
2024-03-19 18:14:58 +00:00
HASUMI Hitoshi
ce544f8dbd
[ruby/prism] [Compatibility] Improve printf format
...
For better compatibility, this patch suggests using __MINGW_PRINTF_FORMAT that GCC provides for MINGW environment.
https://github.com/ruby/prism/commit/a3a792b64f
2024-03-19 01:30:38 +00:00
Kevin Newton
548203eaf2
[ruby/prism] Warn on frozen_string_literal after tokens
...
https://github.com/ruby/prism/commit/edece87801
2024-03-18 17:00:07 +00:00
Kevin Newton
8514785e94
[ruby/prism] CRuby error message for lonely else
...
https://github.com/ruby/prism/commit/1219a709e4
2024-03-18 16:59:58 +00:00
Koichi ITO
7a1a572428
[ruby/prism] Use `require_relative` in the Prism codebase
...
If there are many searches in the `$LOAD_PATH` in the user environment,
require will perform unnecessary searches that are not needed.
In contrast, `require_relative` is efficient because it uses a relative path.
https://github.com/ruby/prism/commit/438ccc67bd
2024-03-18 16:12:49 +00:00
Jean Boussier
f2e96d4bd9
[ruby/prism] Add PM_STRING_FLAGS_FROZEN / PM_STRING_FLAGS_MUTABLE on PM_SOURCE_FILE_NODE
...
For all intent and purposes, `__FILE__` is a string literal subject
to the `# frozen_string_literal: true/false` comment and to the
global `--enable-frozen-string-literal / --disable-frozen-string-literal`
CLI flags.
https://github.com/ruby/prism/commit/7e33c92afd
2024-03-15 13:31:02 +00:00
Kevin Newton
c45ad17fa1
[ruby/prism] Shareable constant nodes
...
https://github.com/ruby/prism/commit/473cfed6d0
2024-03-15 12:31:26 +00:00
Kevin Newton
2cfcebb2a8
[ruby/prism] Warn for maximum number variables
...
https://github.com/ruby/prism/commit/2cdbf81c95
2024-03-13 18:35:18 +00:00
Kevin Newton
c17f33aa42
[ruby/prism] Only use e suffix for floats if followed by +, -, or digit
...
https://github.com/ruby/prism/commit/164de502c9
2024-03-13 17:00:03 +00:00
Kevin Newton
a05dfbd405
[PRISM] Remove ssize_t definition from prism
2024-03-13 12:06:48 -04:00
Kevin Newton
4dd9602c6f
[ruby/prism] Remove ssize_t usage
...
https://github.com/ruby/prism/commit/64c4f1268b
2024-03-13 16:06:13 +00:00
Kevin Newton
572e791567
[ruby/prism] FSL follow-up
...
https://github.com/ruby/prism/commit/097fd2a54f
2024-03-13 16:05:46 +00:00
Jean Boussier
53a77d9b90
[ruby/prism] Change `frozen_string_literal` to be a tri-state
...
An explicit `false` is not equivalent to the comment being missing,
because the default can be switched with a runtime flag:
```bash
$ ruby --enable-frozen-string-literal -e 'p "foo".frozen?'
true
```
https://github.com/ruby/prism/commit/4660f58775
2024-03-13 16:03:24 +00:00
Kevin Newton
d1eaa97ec3
[ruby/prism] Track parentheses in patterns
...
https://github.com/ruby/prism/commit/62db99f156
2024-03-13 13:52:13 +00:00
Koichi ITO
5fa28ce015
[ruby/prism] Warn `&` interpreted as argument prefix
...
This PR makes `Prism` warn `&` interpreted as argument prefix.
This carries a similar meaning to the following Ruby warning:
```console
$ ruby -cwe "foo &bar"
-e:1: warning: `&' interpreted as argument prefix
Syntax OK
```
Previously, it did not issue a warning:
```console
$ bundle exec ruby -rprism -ve "p Prism.parse('foo &bar').warnings"
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75 ) [x86_64-darwin22]
[]
```
From now on, it will issue a warning similar to Ruby's:
```console
$ bundle exec ruby -rprism -ve "p Prism.parse('foo &bar').warnings"
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75 ) [x86_64-darwin22]
[#<Prism::ParseWarning @type=:ambiguous_prefix_amp @message="ambiguous `&` has been interpreted as an argument prefix"
@location=#<Prism::Location @start_offset=4 @length=1 start_line=1> @level=:verbose>]
```
https://github.com/ruby/prism/commit/312f99cd1e
2024-03-13 12:38:45 +00:00
Koichi ITO
824e3e6c3d
[ruby/prism] Warn `**` interpreted as argument prefix
...
This PR makes Prism warn `**` interpreted as argument prefix.
This carries a similar meaning to the following Ruby warning:
```console
$ ruby -cwe "foo **bar"
-e:1: warning: `**' interpreted as argument prefix
Syntax OK
```
Previously, it did not issue a warning:
```console
$ bundle exec ruby -rprism -ve "p Prism.parse('foo **bar').warnings"
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75 ) [x86_64-darwin22]
[]
```
From now on, it will issue a warning similar to Ruby's:
```console
$ bundle exec ruby -rprism -ve "p Prism.parse('foo **bar').warnings"
ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75 ) [x86_64-darwin22]
[#<Prism::ParseWarning @type=:ambiguous_prefix_star_star @message="ambiguous `**` has been interpreted as an argument prefix"
@location=#<Prism::Location @start_offset=4 @length=2 start_line=1> @level=:verbose>]
```
https://github.com/ruby/prism/commit/f6cb5c314c
2024-03-13 12:38:44 +00:00
Kevin Newton
a6582ac94a
[ruby/prism] Allow newline before block locals
...
https://github.com/ruby/prism/commit/1d4df7d874
2024-03-13 01:40:28 +00:00
Kevin Newton
248cf0e40a
[ruby/prism] Move index tracking into a call node flag
...
https://github.com/ruby/prism/commit/2a2e216558
2024-03-12 22:29:54 +00:00
Kevin Newton
e914fa0d10
[ruby/prism] Add warning for chained comparisons
...
https://github.com/ruby/prism/commit/f9f3620d44
2024-03-12 22:29:54 +00:00
Kevin Newton
157733b1b7
[ruby/prism] Add whitespace warnings
...
https://github.com/ruby/prism/commit/01d137a0cb
2024-03-12 22:29:53 +00:00
Kevin Newton
5c84850591
[ruby/prism] Warnings for incorrect character literal syntax
...
https://github.com/ruby/prism/commit/909508296e
2024-03-12 22:29:53 +00:00
Kevin Newton
83790e5fe1
[ruby/prism] Consolidate warnings for conditional predicates
...
* Also add warnings for literals in predicates
* Also create flip-flops in while/until
https://github.com/ruby/prism/commit/a6b5c523c2
2024-03-12 17:32:06 +00:00
Nobuyoshi Nakada
f42164e037
Define `ssize_t` on mswin build
2024-03-12 14:49:25 +09:00
Kevin Newton
21ea290b34
[ruby/prism] Static literals inspect
...
https://github.com/ruby/prism/commit/4913d112da
2024-03-12 03:30:50 +00:00
matthew healy
132df4d1d4
[ruby/prism] Document `InstanceVariableWriteNode` fields
...
(https://github.com/ruby/prism/pull/2161 )
* Document InstanceVariableWriteNode fields
* Reference lexing docs in name field documentation
* Update config.yml
---------
https://github.com/ruby/prism/commit/015b3a857e
Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-03-11 19:46:29 +00:00
matthew healy
e407e3f497
[ruby/prism] Document `ClassVariableWriteNode` fields
...
(https://github.com/ruby/prism/pull/2162 )
* Make ClassVariableWriteNode operator_loc non-nullable
* Document ClassVariableWriteNode fields
* Update config.yml
---------
https://github.com/ruby/prism/commit/659b133888
Co-authored-by: Kevin Newton <kddnewton@gmail.com>
2024-03-11 19:45:58 +00:00
Kevin Newton
6242a82c8f
[ruby/prism] Provide more documentation for pm_integer_parse_digit_values
...
https://github.com/ruby/prism/commit/c3fcb5031f
2024-03-11 15:12:14 +00:00
Kevin Newton
2dfa95a272
[ruby/prism] Stop crashing on invalid integers
...
https://github.com/ruby/prism/commit/afac2d6646
2024-03-11 15:11:42 +00:00
Kevin Newton
2ab75bc444
[ruby/prism] Support offset
...
https://github.com/ruby/prism/commit/665f533373
2024-03-11 14:49:23 +00:00
Kevin Newton
35c20cda70
[ruby/prism] Simplify the regular expression ASCII-only check
...
https://github.com/ruby/prism/commit/b7851f4c2d
2024-03-08 19:18:42 +00:00
Kevin Newton
cfcbbbd87c
[ruby/prism] Simplify the ASCII-only check in regexp
...
https://github.com/ruby/prism/commit/b0935be727
2024-03-08 19:18:42 +00:00
Kevin Newton
609bbad15d
[ruby/prism] Fix up regexp memory leaks
...
https://github.com/ruby/prism/commit/4dc58a533a
2024-03-08 18:48:55 +00:00
Kevin Newton
a564f30fb8
[ruby/prism] Extract out pm_regexp_token_buffer_t
...
https://github.com/ruby/prism/commit/7bbe4224a3
2024-03-08 18:48:55 +00:00
Kevin Menard
4e1d19c457
[ruby/prism] Add initial implementation of `Regexp` validation.
...
https://github.com/ruby/prism/commit/6bf1b8edf0
2024-03-08 18:48:54 +00:00
Kevin Menard
d473256abe
[ruby/prism] Extract a magic value to a named constant.
...
https://github.com/ruby/prism/commit/54d14a35a9
2024-03-08 18:48:54 +00:00
Kevin Menard
82fb6a90d5
[ruby/prism] Track both the unescaped bytes and source string for a regular expression so we can accurately set its encoding flags.
...
https://github.com/ruby/prism/commit/dc6dd3a926
2024-03-08 18:48:53 +00:00
Kevin Newton
7e1183200a
[ruby/prism] Fix up test suite
...
https://github.com/ruby/prism/commit/2929c35630
2024-03-07 23:13:41 +00:00
Kevin Newton
f5294ebbdb
[ruby/prism] Shared integer parsing logic
...
https://github.com/ruby/prism/commit/a2594a23c1
2024-03-07 18:02:33 -05:00
Kevin Newton
c1462250b8
[ruby/prism] Style and allocation functions
...
https://github.com/ruby/prism/commit/97f838c323
2024-03-07 18:02:33 -05:00
tompng
81f02eb6ba
[ruby/prism] Change pm_integer_t structure
...
https://github.com/ruby/prism/commit/588acf823f
2024-03-07 18:02:33 -05:00
tompng
5113d6b059
[ruby/prism] Faster pm_integer_parse pm_integer_string using karatsuba algorithm
...
https://github.com/ruby/prism/commit/ae4fb6b988
2024-03-07 18:02:33 -05:00
tompng
05526a444c
[ruby/prism] Make pm_integer -> Integer faster
...
https://github.com/ruby/prism/commit/47601e7928
2024-03-07 18:02:33 -05:00
Kevin Newton
977012bae8
[ruby/prism] Remove restrict to fix windows 2015
...
https://github.com/ruby/prism/commit/f0a2ce1c0e
2024-03-07 21:23:18 +00:00
Kevin Newton
ec159fc8ba
[ruby/prism] Support parsing streams
...
https://github.com/ruby/prism/commit/efdc2b7222
2024-03-07 20:40:39 +00:00
Kevin Newton
76e11595e2
[ruby/prism] Fix up tilde heredoc line continuations
...
https://github.com/ruby/prism/commit/15e74b2f65
2024-03-07 20:25:24 +00:00
Kevin Newton
5141643a27
[ruby/prism] Fix rebase templates
...
https://github.com/ruby/prism/commit/31b8c6142f
2024-03-06 21:42:54 -05:00
Kevin Newton
d266b71467
[ruby/prism] Use the diagnostic types in the parser translation layer
...
https://github.com/ruby/prism/commit/1a8a0063dc
2024-03-06 21:42:54 -05:00
Kevin Newton
38c2774420
[ruby/prism] Expose types on diagnostics
...
https://github.com/ruby/prism/commit/a735c2262f
2024-03-06 21:42:54 -05:00
Ufuk Kayserilioglu
8d191a9f57
[ruby/prism] Move polyfill to separate file to type-check it independently.
...
https://github.com/ruby/prism/commit/2a583b041b
2024-03-06 21:37:53 +00:00
Ufuk Kayserilioglu
3ad17b3bec
[ruby/prism] `Prism::Compiler` should be a subclass of `Prism::Visitor`
...
https://github.com/ruby/prism/commit/a01d6a4e32
2024-03-06 21:37:53 +00:00
Ufuk Kayserilioglu
ddc81ee3f9
[ruby/prism] Fix some missing methods/signatures in RBIs
...
https://github.com/ruby/prism/commit/1d87b8c46c
2024-03-06 21:37:51 +00:00
Ufuk Kayserilioglu
2e1d735dce
[ruby/prism] Move template related methods/classes under `Prism::Template` namespace
...
https://github.com/ruby/prism/commit/0e4dbcd3e4
2024-03-06 21:37:49 +00:00
Kevin Newton
b88973165a
[ruby/prism] Parse files from Ruby API using fread, not mmap
...
https://github.com/ruby/prism/commit/62d4376a53
2024-03-06 17:45:56 +00:00
cui fliter
226a889dc7
[DOC] fix some comments
...
Signed-off-by: cui fliter <imcusg@gmail.com>
2024-03-05 18:50:47 +09:00
Kevin Newton
50e9a6b7c5
[ruby/prism] Provide API for visiting in C
...
https://github.com/ruby/prism/commit/537947aa5c
2024-03-04 20:24:20 +00:00
Nobuyoshi Nakada
20123008da
[ruby/prism] Drop support for old ERB
...
https://github.com/ruby/prism/commit/acdff3aae3
2024-03-04 20:06:53 +00:00
Kevin Newton
e78a705f01
[ruby/prism] Warnings for tokens at EOL
...
https://github.com/ruby/prism/commit/d0dbf01bef
2024-03-04 18:09:48 +00:00
Kevin Newton
f7adee34a3
[ruby/prism] Only define xallocator when not defined
...
https://github.com/ruby/prism/commit/919d682379
2024-03-04 16:49:14 +00:00
Benoit Daloze
6ad0f89d5a
[ruby/prism] Use a more efficient StringIO on TruffleRuby
...
* The stdlib StringIO is synchronized and this occurs a high overhead.
* This is about twice as fast on TruffleRuby but surprisingly it is slower on JRuby.
I am not sure why but probably @ivar access and integer arithmetic
is much slower than Java field access/arithmetic on JRuby.
* On CRuby interpreter it is slower, which is expected as the GVL already protects StringIO.
* So we enable this only on TruffleRuby to not slow down other Rubies.
* PRISM_FFI_BACKEND=true ruby -v -Ilib -rprism -rbenchmark -e '300.times { p Benchmark.realtime { Dir.glob("lib/**/*.rb") { |f| Prism.parse_file(f) } } }'
ruby 3.3.0: 0.215 => 0.251 (cext: 0.062)
ruby 3.3.0 YJIT: 0.118 => 0.113 (cext: 0.053)
truffleruby JVM: 0.101 => 0.054
jruby 9.4.6.0: 0.162 => 0.219
jruby 9.4.6.0 indy: 0.078 => 0.086
* For the record here are the numbers for using the String directly, without a StringIO-like object:
ruby 3.3.0: 0.215 => 0.234 (cext: 0.062)
ruby 3.3.0 YJIT: 0.118 => 0.111 (cext: 0.053)
truffleruby native: 0.101 => 0.053
jruby 9.4.6.0: 0.162 => 0.195
jruby 9.4.6.0 indy: 0.078 => 0.082
As we can see, that extra object adds a non-trivial overhead on CRuby interpreter and JRuby.
But we need to make it possible to use StringIO and SimpleStringIO interchangeably.
https://github.com/ruby/prism/commit/938677cbd2
2024-03-04 16:41:16 +00:00
Kevin Newton
03a73fdc3d
[ruby/prism] Add then keyword loc to when nodes
...
https://github.com/ruby/prism/commit/e1e613df16
2024-03-04 16:40:37 +00:00
Kevin Newton
c0a34a6c8c
[ruby/prism] Document xallocator functions
...
https://github.com/ruby/prism/commit/ee1a4acacd
2024-03-04 16:40:24 +00:00
HASUMI Hitoshi
b95e2cdca7
[ruby/prism] Additional fix of adding `x` prefix after rebase with main branch
...
https://github.com/ruby/prism/commit/08733438bd
2024-03-04 16:40:24 +00:00
HASUMI Hitoshi
54f27549e2
[ruby/prism] Chage some names
...
- PRISM_CUSTOM_ALLOCATOR -> PRISM_XALLOCATOR
- prism_custom_allocator.h -> prism_xallocator.h
https://github.com/ruby/prism/commit/83b4071e5b
2024-03-04 16:40:23 +00:00
HASUMI Hitoshi
c4bd6da298
[ruby/prism] Make alloc interface replaceable
...
- Add `x` prefix to malloc, calloc, realloc, and free
(eg: malloc -> xmalloc)
- By default, they are replaced with stdlib's functions at build
- You can use custom functions by defining `PRISM_CUSTOM_ALLOCATOR` macro
https://github.com/ruby/prism/commit/7a878af619
2024-03-04 16:40:23 +00:00
Benoit Daloze
d5ae7965b7
[ruby/prism] Lazily create Location objects in Prism::Serialize::Loader#load_location
...
* Following the changes in #2428 .
* PRISM_FFI_BACKEND=true ruby -v -Ilib -rprism -rbenchmark -e '10.times { p Benchmark.realtime { Dir.glob("lib/**/*.rb") { |f| Prism.parse_file(f) } } }'
ruby 3.3.0: 0.255 => 0.210
ruby 3.3.0 YJIT: 0.150 => 0.120
https://github.com/ruby/prism/commit/fabf809bbf
2024-02-29 19:24:04 +00:00
Kevin Newton
1c0c490aa0
[ruby/prism] Warn on integers in flip-flops
...
https://github.com/ruby/prism/commit/500099e896
2024-02-29 17:32:37 +00:00
Kevin Newton
50e999c56d
[ruby/prism] Command line options as a bitset
...
https://github.com/ruby/prism/commit/369ffbd57e
2024-02-29 12:05:19 -05:00
Kevin Newton
cd8d1018bb
[ruby/prism] Resync RBI and test it in CI
...
https://github.com/ruby/prism/commit/4ef4032774
2024-02-29 16:29:16 +00:00
Kevin Newton
cb784082bc
[ruby/prism] Better hashing between positive/negative integers
...
https://github.com/ruby/prism/commit/68ddf08634
2024-02-29 14:53:42 +00:00
Benoit Daloze
a5bfc25107
[ruby/prism] Rewrite logic for CHECK_FIELD_KIND to improve readability
...
https://github.com/ruby/prism/commit/f731edcc26
2024-02-28 18:30:44 +00:00
Benoit Daloze
7167346461
[ruby/prism] More precise types for NodeListField in prism.rbi
...
https://github.com/ruby/prism/commit/b7959295e9
2024-02-28 18:30:44 +00:00
Benoit Daloze
2143789a33
[ruby/prism] Make NodeKindField subclass NodeKindField
...
* To avoid duplication.
https://github.com/ruby/prism/commit/12e5aae0b4
2024-02-28 18:30:44 +00:00
Benoit Daloze
1b0a5bcb0a
[ruby/prism] Add a simple way to check field kinds are correct by setting $CHECK_FIELD_KIND
...
https://github.com/ruby/prism/commit/33e987ba3c
2024-02-28 18:30:43 +00:00
Benoit Daloze
ea2cb00250
[ruby/prism] Give a kind to all node[] fields which can have one more specific than "any Node"
...
* Fixes https://github.com/ruby/prism/issues/2058
https://github.com/ruby/prism/commit/f3e3310b5e
2024-02-28 18:30:43 +00:00
Benoit Daloze
567d4ee79e
[ruby/prism] Set proper types for node[] in Java-generated code
...
https://github.com/ruby/prism/commit/322eaea500
2024-02-28 18:30:42 +00:00
Kevin Newton
c990cc706c
[ruby/prism] Switch static literals to use a hash
...
https://github.com/ruby/prism/commit/82e6f36e8f
2024-02-28 15:36:16 +00:00
Kevin Newton
8b556d39d2
[ruby/prism] Refactor static literals into hash
...
https://github.com/ruby/prism/commit/62382d3967
2024-02-28 15:36:15 +00:00
Kevin Newton
e14a68a1bf
[ruby/prism] Disallow it implicit in eval
...
https://github.com/ruby/prism/commit/6fcb8fc974
2024-02-27 18:00:43 +00:00
Kevin Newton
f67c9d001a
[ruby/prism] Switch invalid _1 targeting even on syntax error
...
https://github.com/ruby/prism/commit/40dec909b7
2024-02-27 16:05:03 +00:00
Kevin Newton
fc36882713
[ruby/prism] Ensure symbol nodes not in interpolated symbol
...
https://github.com/ruby/prism/commit/e1a9a1d478
2024-02-27 16:05:02 +00:00
Kevin Newton
3ca8b4aee0
[ruby/prism] Support -p, -n, -a, and -l command line options
...
https://github.com/ruby/prism/commit/959eb506ca
2024-02-27 04:22:39 +00:00
Kevin Newton
34bad6d69f
[ruby/prism] Triple-check prism encodings
...
https://github.com/ruby/prism/commit/ab7f261354
2024-02-26 18:29:00 +00:00
Kevin Newton
1a57fee7af
[ruby/prism] Fix multi write with modifier rescue
...
https://github.com/ruby/prism/commit/8ea7a3270f
2024-02-26 13:58:57 +00:00
Gopal Patel
aa8841405b
[ruby/prism] Less code modifications. More steep:ignore for now
...
https://github.com/ruby/prism/commit/7905bdbf83
2024-02-24 03:39:28 +00:00
Gopal Patel
dfee033746
[ruby/prism] Replace awkward code changes with steep:ignore
...
Also remove RBS for currently ignored files. Will follow-up when those
check fully in later PRs.
https://github.com/ruby/prism/commit/2cae58f86d
2024-02-24 03:39:28 +00:00
Gopal Patel
8fa1843523
[ruby/prism] Relax Location#source to be optional
...
https://github.com/ruby/prism/commit/9f00fe7510
2024-02-24 03:39:26 +00:00
Gopal Patel
935d4fab62
[ruby/prism] Remove Ripper from public RBS, type-assert remaining issues
...
https://github.com/ruby/prism/commit/5fda7a0760
2024-02-24 03:39:23 +00:00
Gopal Patel
7556fd937c
[ruby/prism] Split private types
...
https://github.com/ruby/prism/commit/0209d093ec
2024-02-24 03:39:22 +00:00
Gopal Patel
e03e9c3644
[ruby/prism] wip: node unions
...
https://github.com/ruby/prism/commit/99a71675d4
2024-02-24 03:39:20 +00:00
Gopal Patel
b9b0712556
[ruby/prism] Use steep to type check RBS and Ruby files
...
https://github.com/ruby/prism/commit/eabed9f4fd
2024-02-24 03:39:19 +00:00
Kevin Newton
fc656acee9
[PRISM] Sync to latest prism
2024-02-23 21:56:56 -05:00
Kevin Newton
96907f9495
[ruby/prism] Convert pm_integer_t to strings
...
https://github.com/ruby/prism/commit/fa9a30ad91
2024-02-23 21:54:01 +00:00
Kevin Newton
ec6532b458
[ruby/prism] Add some encoding debugging to make testing easier
...
https://github.com/ruby/prism/commit/0c042561c6
2024-02-23 20:02:19 +00:00
Kevin Newton
02b531a813
[ruby/prism] Factor in sign to integer comparison
...
https://github.com/ruby/prism/commit/377666a5df
2024-02-23 13:25:31 -05:00
Kevin Newton
b9202788f8
[ruby/prism] Refactor pm_node_list_insert to use a binary search
...
https://github.com/ruby/prism/commit/a060b21e1d
2024-02-23 13:25:31 -05:00
Kevin Newton
a38cc177d2
[ruby/prism] Duplicated when clauses
...
https://github.com/ruby/prism/commit/865b0d5fbe
2024-02-23 13:25:31 -05:00
Kevin Newton
d1ce989829
[ruby/prism] Duplicated hash keys
...
https://github.com/ruby/prism/commit/3e10c46c14
2024-02-23 13:25:31 -05:00
Mike Shaver
32f8ed7afd
Typo fix.
2024-02-23 12:54:31 -05:00
Kevin Newton
a154ea0c91
[ruby/prism] Ignore other ERANGE errors for floats
...
https://github.com/ruby/prism/commit/4267161ca7
2024-02-22 22:42:44 -05:00
Kevin Newton
5e0589cf52
[ruby/prism] Parse float values
...
https://github.com/ruby/prism/commit/9137226a52
2024-02-22 22:42:44 -05:00
Kevin Newton
3b3def5db7
[ruby/prism] Regenerate snapshots using integer values
2024-02-22 22:42:44 -05:00
Kevin Newton
af0a6ea1d5
[ruby/prism] Add an IntegerField for parsing integer values
...
https://github.com/ruby/prism/commit/120d8c0479
2024-02-22 22:42:44 -05:00
Kevin Newton
ff6ebba9de
[ruby/prism] Parse numeric values
...
https://github.com/ruby/prism/commit/a6a552411c
2024-02-22 22:42:44 -05:00
Kevin Newton
31735d77c5
[ruby/prism] Update for Ruby 3.4 errors
...
https://github.com/ruby/prism/commit/20fea2cf2b
2024-02-21 17:55:11 -05:00
Kevin Newton
90c5393f9f
[ruby/prism] Support ItParametersNode
...
So that compilers know they need to add to add an anonymous
variable to the local table.
https://github.com/ruby/prism/commit/7f1aadd057
2024-02-21 17:55:11 -05:00
Kevin Newton
2b2e61e6f9
[ruby/prism] Only call encoding_changed callback on change
...
https://github.com/ruby/prism/commit/7d0bea3ce0
2024-02-21 15:47:05 +00:00
Kevin Newton
bf680af7b2
[ruby/prism] Remove non-ASCII characters from --dump=parsetree
...
https://github.com/ruby/prism/commit/6d4cd21e98
2024-02-21 15:22:41 +00:00
Kevin Newton
20f03100d5
[ruby/prism] Fix eval encoding switching to UTF-8
...
https://github.com/ruby/prism/commit/24e3ff5d6d
2024-02-20 15:36:35 +00:00
Kevin Newton
bcfcdae58e
[ruby/prism] Fix windows build checking for _POSIX_MAPPED_FILES
...
https://github.com/ruby/prism/commit/acf603603f
2024-02-20 14:31:03 +00:00
HASUMI Hitoshi
f0a46c6334
[ruby/prism] Include unistd.h before cheching _POSIX_MAPPED_FILES
...
https://github.com/ruby/prism/commit/84b3c294f0
2024-02-20 14:21:17 +00:00
HASUMI Hitoshi
15b53e901c
[ruby/prism] Use `_POSIX_MAPPED_FILES` and `_WIN32` to know if memory map interface is available in the target platform
...
https://github.com/ruby/prism/commit/88e2ff52d4
2024-02-20 14:21:16 +00:00
Kevin Newton
ec1eda7b62
[ruby/prism] Account for encoding in regexp named captures
...
https://github.com/ruby/prism/commit/17dc6b6281
2024-02-18 21:42:09 +00:00
Kevin Newton
ea529dd409
[ruby/prism] Lazy methods for start and end offset on node
...
https://github.com/ruby/prism/commit/4510e2746d
2024-02-18 21:37:13 +00:00
Kevin Newton
00bda2aa3b
[ruby/prism] Fix up GCC analyzer
...
https://github.com/ruby/prism/commit/2e8bc17528
2024-02-17 21:53:54 +00:00
Kevin Newton
b56b8ec797
[ruby/prism] Provide the ability to dump AST to JSON from C
...
https://github.com/ruby/prism/commit/d3a149efc5
2024-02-17 02:05:12 +00:00
Kevin Newton
429338a20c
[ruby/prism] Accept newlines before ) in patterns
...
https://github.com/ruby/prism/commit/e5ffb7bdf8
2024-02-16 20:41:40 +00:00
Kevin Newton
6f4bb638b0
[ruby/prism] Builtins
...
https://github.com/ruby/prism/commit/851f2571ff
2024-02-16 19:34:38 +00:00
Kevin Newton
8e4d1ff5da
[ruby/prism] Disallow numbered parameters within given scopes
...
https://github.com/ruby/prism/commit/a218a0f265
2024-02-16 17:50:32 +00:00
Kevin Newton
ff4f5c0cdd
[ruby/prism] Style/renaming
...
https://github.com/ruby/prism/commit/53763d67d5
2024-02-16 15:49:50 +00:00
Kevin Newton
04e7c5749b
[ruby/prism] Fix pattern with constant, (, and newlines
...
https://github.com/ruby/prism/commit/d69d1b6f17
2024-02-16 15:35:58 +00:00
Haldun Bayhantopcu
f4f57e1162
[ruby/prism] Add warning for assignments to literals in conditionals
...
https://github.com/ruby/prism/commit/ee87ed08fb
2024-02-16 15:33:07 +00:00
Benoit Daloze
1b9b960963
[ruby/prism] Make location methods thread-safe
...
* Before it could result in NoMethodError if multiple threads were
calling location methods: https://gist.github.com/eregon/b78b7f266d7ee0a278a389cfd1782232
https://github.com/ruby/prism/commit/ff762dcccd
2024-02-15 23:04:38 +00:00
Kevin Newton
e7f7a85285
[PRISM] Sync prism version bump
2024-02-15 15:50:04 -05:00
Kevin Newton
14a7277da1
[ruby/prism] Speed up creating Ruby AST
...
When creating the Ruby AST, we were previously allocating Location
objects for every node and every inner location. Instead, this
commit changes it to pack both the start offset and length into a
single u64 and pass that into the nodes. Then, when the locations
are requested via a reader method, we lazily allocate the Location
objects.
https://github.com/ruby/prism/commit/de203dca83
Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
2024-02-15 20:39:50 +00:00
Max Prokopiev
49ddbbf39f
[ruby/prism] Fix opening loc for an empty symbol
...
https://github.com/ruby/prism/commit/241d0169da
2024-02-15 20:28:17 +00:00
Haldun Bayhantopcu
a6bcd3aa70
[ruby/prism] Fix debug logging
...
https://github.com/ruby/prism/commit/01af2d4f39
2024-02-15 16:41:05 +00:00
Haldun Bayhantopcu
a021702596
[ruby/prism] Fix parsing rescue modifier
...
https://github.com/ruby/prism/commit/b7407ae3c0
2024-02-15 16:40:36 +00:00
Yusuke Endoh
d5c16ddfcb
Temporarily update the error message format in prism
2024-02-15 18:42:31 +09:00
Kevin Newton
9933377c34
[PRISM] Correctly hook up line numbers for eval
2024-02-14 15:29:26 -05:00
Benoit Daloze
f4a0e1cdb4
Prefer `Array.new(n) {}` to `n.times.map {}`
...
* It is quite a bit faster:
ruby -rbenchmark/ips -e 'Benchmark.ips { |x| x.report("times.map") { 1000.times.map {} }; x.report("Array.new") { Array.new(1000) {} }; x.compare! }'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75
) [x86_64-linux]
Warming up --------------------------------------
times.map 976.000 i/100ms
Array.new 1.641k i/100ms
Calculating -------------------------------------
times.map 9.808k (± 0.3%) i/s - 49.776k in 5.075013s
Array.new 16.601k (± 1.0%) i/s - 83.691k in 5.041970s
Comparison:
Array.new: 16600.8 i/s
times.map: 9808.2 i/s - 1.69x slower
2024-02-14 15:56:42 +00:00
Benoit Daloze
c2d8d6eba6
Initialize the Prism::Source directly with all 3 fields for the C extension
...
* Faster that way:
$ ruby -Ilib -rprism -rbenchmark/ips -e 'Benchmark.ips { |x| x.report("parse") { Prism.parse("1 + 2") } }'
195.722k (± 0.5%) i/s
rb_iv_set():
179.609k (± 0.5%) i/s
rb_funcall():
190.030k (± 0.3%) i/s
before this PR:
183.319k (± 0.4%) i/s
2024-02-14 15:48:33 +00:00
Benoit Daloze
1b2708b123
[ruby/prism] Remove attr_writer's for ParseResult#start_line and #offsets
...
* As the user should not set these.
* Use #instance_variable_set/rb_iv_set() instead internally.
https://github.com/ruby/prism/commit/cace09fb8c
2024-02-14 15:48:33 +00:00
Benoit Daloze
f0f6ffef42
[ruby/prism] Serialize the newline_list to avoid recomputing it again later
...
* Fixes https://github.com/ruby/prism/issues/2380
https://github.com/ruby/prism/commit/4eaaa90114
2024-02-14 15:48:32 +00:00
Kevin Newton
12b0e67fec
[PRISM] Sync to latest prism
2024-02-14 09:58:36 -05:00
Kevin Newton
068b19bd53
[ruby/prism] Match up token name to CRuby
...
https://github.com/ruby/prism/commit/cf0369a5c7
2024-02-14 01:42:01 +00:00
Kevin Newton
2fa051f627
[ruby/prism] Validate multibyte characters in strings
...
Check that multibyte characters are valid using pm_strpbrk. We need
to add a couple of codepaths to ensure all encodings are covered.
Importantly this doesn't check regular expressions, because
apparently you're allowed to have invalid multibyte characters
inside regular expression comment groups/extended mode.
https://github.com/ruby/prism/commit/2857d3e1b5
2024-02-14 01:01:37 +00:00
Kevin Newton
dc5191d695
[ruby/prism] Fix KOI-8 char width check
...
https://github.com/ruby/prism/commit/06d3747c5b
2024-02-13 21:12:10 +00:00
Kevin Newton
a96110f7ef
[ruby/prism] Convert more error messages to match specs
...
https://github.com/ruby/prism/commit/7987b7aa20
2024-02-13 20:35:02 +00:00
Kevin Newton
29d04bb0c4
[ruby/prism] Introduce `version: "3.4.0"`
...
This is effectively an alias for "latest" right now. In the future
it will change to be its own enum value.
https://github.com/ruby/prism/commit/2c86036022
2024-02-13 18:26:28 +00:00
Koichi ITO
246005f5bd
[ruby/prism] Fix an error when specifying the parsing version `latest`
...
This PR fixes following error when using `version: latest` argument.
```console
$ ruby -rprism -e "p Prism.parse('-> { it }', version: 'latest')"
-e:1:in `parse': invalid version: latest (ArgumentError)
p Prism.parse('-> { it }', version: 'latest')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
from -e:1:in `<main>'
```
The argument `version: latest` in the added test is commented as potentially being
better replaced with `version: 3.4.0` in the future.
https://github.com/ruby/prism/commit/27b5c933cb
2024-02-13 18:15:48 +00:00
Kevin Newton
bb845ae879
[ruby/prism] Fix typo in class variable name error
...
https://github.com/ruby/prism/commit/5f6c45f6fb
2024-02-12 20:03:09 +00:00
Kevin Newton
e08c128417
[ruby/prism] Error messages closer to CRuby
...
https://github.com/ruby/prism/commit/19ffa0b980
2024-02-12 18:01:45 +00:00
Kevin Newton
c3886c12dc
[ruby/prism] Fix unary not location
...
https://github.com/ruby/prism/commit/861689f6d1
2024-02-12 16:27:49 +00:00
Kevin Newton
78deba1aa1
[ruby/prism] Unary not name location
...
https://github.com/ruby/prism/commit/78190d2999
2024-02-12 15:57:17 +00:00
Kevin Newton
3ecfc3e33e
[PRISM] Support the DATA constant
2024-02-08 14:36:29 -05:00
Kevin Newton
54295ba5e1
[PRISM] Compile constant reads using opt_getconstant_path
2024-02-08 11:53:10 -05:00
Kevin Newton
fcc8df622a
Bump prism version
2024-02-07 13:36:06 -05:00
Kevin Newton
aad3c36bdf
[ruby/prism] Support for Ruby 2.7
...
https://github.com/ruby/prism/commit/1a15b70a8e
2024-02-07 16:54:34 +00:00
eileencodes
936c0ab5e8
[ruby/prism] Implement file parsing error handling
...
This PR implements proper file parsing error handling. Previously
`file_options` would call `pm_string_mapped_init` which would print an
error from `perror`. However this wouldn't raise a proper Ruby error so
it was just a string output. I've done the following:
- Raise an error from `rb_syserr_fail` with the filepath in
`file_options`.
- No longer return `Qnil` if `file_options` returns false (because now
it will raise)
- Update `file_options` to return `static void` instead of `static
bool`.
- Update `file_options` and `profile_file` to check the type so when
passing `nil` we see a `TypeError`.
- Delete `perror` from `pm_string_mapped_init`
- Update `FFI` backend to raise appropriate errors when calling
`pm_string_mapped_init`.
- Add tests for `dump_file`, `lex_file`, `parse_file`,
`parse_file_comments`, `parse_lex_file`, and `parse_file_success?`
when a file doesn't exist and for `nil`.
- Updates the `bin/parse` script to no longer raise it's own
`ArgumentError` now that we raise a proper error.
Fixes : ruby/prism#2207
https://github.com/ruby/prism/commit/b2f7494ff5
2024-02-06 20:49:33 +00:00
Kevin Newton
f5b368df0c
[ruby/prism] Better invalid token messages
...
https://github.com/ruby/prism/commit/8c9bed2a4d
2024-02-06 18:10:50 +00:00
Kevin Newton
c42b1029d9
[ruby/prism] Change the location of an implicit begin to method
...
https://github.com/ruby/prism/commit/d08e140859
2024-02-05 20:40:24 +00:00
Kevin Newton
07611acb0c
[ruby/prism] Add another error type for raising argument errors
...
https://github.com/ruby/prism/commit/f3030cb2b2
2024-02-05 19:24:57 +00:00
Kevin Newton
0b5be2f9e9
Sync to latest prism
2024-02-05 11:07:07 -05:00
Kevin Newton
6afccdf449
[ruby/prism] Provide APIs for finding value in constant pool
...
https://github.com/ruby/prism/commit/be9e2abfa3
2024-02-02 21:45:50 +00:00
Kevin Newton
eaea53b836
[ruby/prism] Handle missing begin body
...
https://github.com/ruby/prism/commit/7e54818b17
2024-02-02 20:43:30 +00:00
Kevin Newton
7695ab3bce
[ruby/prism] Fix up multibyte escapes
...
https://github.com/ruby/prism/commit/836a35f4af
2024-02-02 20:09:01 +00:00
Alan Wu
8f9d999d59
[ruby/prism] Fix overlapping memcpy
...
It's UB to use memcpy with overlapping source and destination. This
might be causing crashes on 32 bit platforms and on OpenBSD. Use memmove
instead. Add a bounds check while we're at it since it's unclear whether
one-past-end pointer with n=0 is UB.
https://github.com/ruby/prism/commit/719f54ff5e
2024-02-02 16:35:43 +00:00
Alan Wu
770b5499a5
[ruby/prism] Amend assert in pm_utf_8_codepoint(), n=0 is fine
...
This assert used to trip in the included test:
```
./miniruby --parser=prism -e ' "%W"\u" '
```
https://github.com/ruby/prism/commit/8c0f84db4f
2024-02-01 22:04:46 +00:00
Kevin Newton
332d2c92d8
[PRISM] Emit parse warnings
2024-02-01 15:52:19 -05:00
Jenny Shen
e4e5a1b4ee
[ruby/prism] Add parentheses around macro arguments
...
https://github.com/ruby/prism/commit/f81fe9c716
Co-authored-by: Adrianna Chang <adrianna.chang@shopify.com>
Co-authored-by: Peter Zhu <peter@peterzhu.ca>
2024-02-01 20:17:37 +00:00
Kevin Newton
29b7c31b08
[ruby/prism] Reject operator writes on operator methods
...
https://github.com/ruby/prism/commit/78bd142e71
2024-02-01 19:45:37 +00:00
Kevin Newton
e9f1324464
Sync to latest prism
2024-02-01 12:52:16 -05:00
Kevin Newton
494778c663
[ruby/prism] Remove locals_body_index
...
We're not using this anymore, and it doesn't make a lot of sense
outside the context of a compiler anyway, and in anyway it's wrong
when you have local variables written in default values.
https://github.com/ruby/prism/commit/5edbd9c25b
2024-02-01 16:48:55 +00:00
Haldun Bayhantopcu
67c5690a6d
[ruby/prism] Check literals for receiver
...
https://github.com/ruby/prism/commit/56441b08e7
2024-02-01 16:48:09 +00:00
Kevin Newton
6ad585bd68
[ruby/prism] Only warn for unary + on spcarg
...
https://github.com/ruby/prism/commit/db0e5ce1ce
2024-02-01 16:13:46 +00:00
Benoit Daloze
9fdfdf4fca
[ruby/prism] Always return the character width for char_is_identifier_start() and char_is_identifier_utf8()
...
* This is also faster than calling pm_encoding_utf_8_alpha_char/pm_encoding_utf_8_alnum_char
as those compute the character width and do extra checks.
https://github.com/ruby/prism/commit/4cb276ac4c
2024-01-31 21:29:16 +00:00