Граф коммитов

946 Коммитов

Автор SHA1 Сообщение Дата
Kevin Newton 74d948a617 [ruby/prism] Better error message on missing hash value
https://github.com/ruby/prism/commit/b20e37e82e
2024-05-08 12:52:54 +00:00
Kevin Newton 21b94ae0d1 [ruby/prism] Extend error message for unterminated HEREDOC
https://github.com/ruby/prism/commit/c1b07ec11b
2024-05-07 18:03:03 +00:00
Kevin Newton dcbe0edb83 [ruby/prism] Better error message for contents of hash pattern
https://github.com/ruby/prism/commit/60dbf60f48
2024-05-07 17:22:50 +00:00
Kevin Newton 5d44846815 [ruby/prism] Disallow implicit hash in array pattern
https://github.com/ruby/prism/commit/bdd509c6ac
2024-05-07 17:15:14 +00:00
Kevin Newton 8ec1c416f7 [ruby/prism] Specific error message for symbol literal with interpolation in hash patterns
https://github.com/ruby/prism/commit/31f0201bae
2024-05-07 16:31:05 +00:00
Kevin Newton 8cc733dff7 [ruby/prism] Add error for invalid implicit local writes
https://github.com/ruby/prism/commit/ab21882561
2024-05-07 16:31:05 +00:00
Kevin Newton eb8efa42f0 [ruby/prism] shareable_constant_value line warnings
https://github.com/ruby/prism/commit/8c984b6922
2024-05-07 14:56:48 +00:00
Kevin Newton d4fdc45953 [ruby/prism] Unexpected fractional component error messages
https://github.com/ruby/prism/commit/e893bc2230
2024-05-06 12:09:48 -04:00
Kevin Newton f92d82ef06 [ruby/prism] More specific error for conflicting forwarding parameters
https://github.com/ruby/prism/commit/1c3b48fedb
2024-05-06 12:09:30 -04:00
Kevin Newton 5909186d02 [ruby/prism] Fix up error message for unexpected {
https://github.com/ruby/prism/commit/80dbe035ba
2024-05-06 15:09:20 +00:00
Kevin Newton d4a6d0c177 [ruby/prism] Prism::Location#adjoin
https://github.com/ruby/prism/commit/a298db68e3
2024-05-03 19:14:03 +00:00
Kevin Newton 7a49edcf1f [ruby/prism] Prism::Node#tunnel
https://github.com/ruby/prism/commit/0bf5d651da
2024-05-03 18:37:19 +00:00
Kevin Newton 1af2dead5a [ruby/prism] Disallow *a&.x=0
https://github.com/ruby/prism/commit/624fdf74bd
2024-05-03 18:14:55 +00:00
Vinicius Stock 4fbb208185 [ruby/prism] Create specialized `ASCIISource` with asciionly optimizations
https://github.com/ruby/prism/commit/40993166a8
2024-05-03 18:10:21 +00:00
Kevin Newton 31361aeca3 [ruby/prism] Disallow safe navigation in a call target node
https://github.com/ruby/prism/commit/b1917adac7
2024-05-03 18:09:35 +00:00
Kevin Newton 2368dab1fa [ruby/prism] Disallow **nil after keyword parameters
https://github.com/ruby/prism/commit/5beeae076f
2024-05-03 13:32:32 -04:00
Kevin Newton 7caeff2bae [ruby/prism] Disallow keywords and blocks in index expressions
https://github.com/ruby/prism/commit/e950dc1e83
2024-05-03 13:01:40 -04:00
Kevin Newton 5758e45657 [ruby/prism] Change ConstantPathNode#child to ConstantPathNode#{name,name_loc}
This has been requested for a long time, and I'm finally doing it
now. Unfortunately this is a breaking change for all of the APIs.

I've added in a Ruby method for `#child` that is deprecated so that
existing usage doesn't break, but for everyone else this is going
to be a bit of a pain.

https://github.com/ruby/prism/commit/9cbe74464e
2024-05-03 11:11:57 -04:00
Kevin Newton 5409661fe6 Mark the first string element of a regexp as binary if US-ASCII 2024-05-02 22:46:09 -04:00
Kevin Newton 7c0cf71049 [ruby/prism] Node#script_lines and supporting infra
https://github.com/ruby/prism/commit/cb4a8ab772
2024-05-02 15:27:18 +00:00
Kevin Newton de6e05da49 [PRISM] Consolidate handling heredoc terminators 2024-05-01 19:19:07 -04:00
Kevin Newton 8ea6daa86d [PRISM] Enable passing tests in test_syntax.rb 2024-05-01 19:19:07 -04:00
Kevin Newton b64fd2f5c5 [PRISM] Closer error messages on invalid unicode escapes in character literals 2024-05-01 19:19:07 -04:00
Kevin Newton 1be5ede766 [PRISM] Error message for unterminated heredoc identifier 2024-05-01 19:19:07 -04:00
Kevin Newton 62f8fb7f89 [PRISM] Fix unterminated regular expression error message 2024-05-01 19:19:07 -04:00
Kevin Newton 5d1e4cd249 [PRISM] Better error messages for unwriteable targets 2024-05-01 19:19:07 -04:00
Kevin Newton 4e8ae5d32a [PRISM] Match unterminated error messages 2024-05-01 19:19:07 -04:00
Kevin Newton 8e1647c3aa [ruby/prism] Support passing version 3.3.1
https://github.com/ruby/prism/commit/445a0f0d22
2024-05-01 23:03:25 +00:00
Kevin Newton 5cd0abdfb5 [PRISM] Simplify prism error highlighting 2024-05-01 16:57:29 -04:00
Kevin Newton fc8fb581cf [ruby/prism] CRuby error message for trailing underscore in number
https://github.com/ruby/prism/commit/4e34f236d3
2024-05-01 19:51:09 +00:00
Kevin Newton efefe42dd1 [ruby/prism] Add more errors for dynamic constant writes in methods
https://github.com/ruby/prism/commit/486e4c0367
2024-05-01 19:02:18 +00:00
Kevin Newton 41f8ae1ffd [ruby/prism] Mark errors for invalid symbols
https://github.com/ruby/prism/commit/661884c4a3
2024-05-01 16:43:05 +00:00
Kevin Newton cfe7019ef5 [ruby/prism] Match CRuby interpolation semantics
If a single string that is a static literal is interpolated, it
does not impact whether or not the parent is a static literal. In
this way, if you have something like a regular expression that
interpolates a string literal, it's possible that you will end up
pushing just a single regexp onto the stack as opposed to calling
out to toregexp.

https://github.com/ruby/prism/commit/4f096c2257
2024-05-01 12:34:29 -04:00
Kevin Newton 3872e54039 [ruby/prism] Bump to v0.27.0
https://github.com/ruby/prism/commit/c9edeef91a
2024-04-26 17:01:03 -04:00
Kevin Newton bb3dd5b808 [PRISM] Sync latest config.yml documentation updates 2024-04-26 17:01:03 -04:00
Kevin Newton 9688093124 [ruby/prism] Location#slice_lines, Node#slice_lines
https://github.com/ruby/prism/commit/9b61f6fdb3
2024-04-26 19:05:32 +00:00
Kevin Newton 0599184a18 [ruby/prism] Match CRuby error messages for invalid numerics
https://github.com/ruby/prism/commit/be21a1bd1d
2024-04-26 18:55:27 +00:00
Kevin Newton 6a296089c6 [ruby/prism] Add a flag on returns when they are redundant
https://github.com/ruby/prism/commit/450541d2c3
2024-04-26 18:10:42 +00:00
Kevin Newton 4c431744b7 [ruby/prism] Warn for nested hashes as well
https://github.com/ruby/prism/commit/76e802f59e
2024-04-24 19:39:42 +00:00
Kevin Newton 7d64fbda53 [ruby/prism] Remove static literals dependence on parser definition
https://github.com/ruby/prism/commit/b3e104e8a2
2024-04-24 19:39:41 +00:00
Kevin Newton 6d9ba1e014 [ruby/prism] Change inspect from recursive to a queue
We would previously cause a stack overflow if we parsed a file that
was too deeply nested when we were calling inspect. Instead, we now
use a queue of commands to do it linearly so we don't.

https://github.com/ruby/prism/commit/0f21f5bfe1
2024-04-24 14:16:42 -04:00
Kevin Newton 0defbc11a5 [ruby/prism] Fix recursive multiply when values are switched in karatsuba_multiply
https://github.com/ruby/prism/commit/4dc6ea960d
2024-04-23 18:17:29 +00:00
Kevin Newton 4f57262338 [ruby/prism] Use GC-able symbols for AST
https://github.com/ruby/prism/commit/801117e45a
2024-04-23 17:26:10 +00:00
Matheus Richard 99a46d7fe9 [ruby/prism] Document UnlessNode fields
https://github.com/ruby/prism/commit/eee8276ae6
2024-04-23 15:20:16 +00:00
Daniel Gollahon b62ab952e3 [ruby/prism] Document `IfNode` fields
- Adds documentation for the fields of the `IfNode`. Also updates the overall description to mention ternary expressions.
- Part of #2123

https://github.com/ruby/prism/commit/fd17c0733d
2024-04-23 15:18:52 +00:00
Matheus Richard b3350e3e6f [ruby/prism] Document BreakNode fields
https://github.com/ruby/prism/commit/7a3ed22f14
2024-04-23 15:11:21 +00:00
Philip Mueller f7d1699f67 [ruby/prism] Implement case equality on nodes
https://github.com/ruby/prism/commit/dc121e4fdf
2024-04-23 13:53:23 +00:00
Cory Hutchison 87b829aa94 [ruby/prism] Document the `AliasGlobalVariableNode` fields
https://github.com/ruby/prism/commit/35bc711069
2024-04-23 13:22:05 +00:00
Sanjay Karukamanna 5fd08b506c [ruby/prism] Document `ArrayNode`, `SourceFileNode` fields
https://github.com/ruby/prism/commit/0bdc566f67
2024-04-23 13:13:29 +00:00
Kevin Newton aa5b53d232 [ruby/prism] Consolidate integer fields into a single reflection class
https://github.com/ruby/prism/commit/0156057580
2024-04-22 14:17:45 +00:00
Kevin Newton 23be6599a2 [ruby/prism] Split parse result based on type
https://github.com/ruby/prism/commit/17194e096d
2024-04-19 19:25:32 +00:00
Kevin Newton cb711df36f [ruby/prism] Do not allow omitted hash keys with ! or ?
https://github.com/ruby/prism/commit/06d358aa8d
2024-04-19 18:20:31 +00:00
Kevin Newton a51139230b [ruby/prism] Bump to v0.26.0
https://github.com/ruby/prism/commit/eadb09ef36
2024-04-18 18:36:57 +00:00
Kevin Newton d186eb36a4 [ruby/prism] Add a reflection API for determining the fields of a node
https://github.com/ruby/prism/commit/f3f9950a74
2024-04-17 13:54:29 -04:00
Kevin Newton f72436f835 [ruby/prism] Inline pm_state_stack 2024-04-17 10:36:52 -04:00
Kevin Newton f34409bf87 [ruby/prism] Fix up more clang-analyzer failures
https://github.com/ruby/prism/commit/f9a1abbc64
2024-04-17 01:15:21 +00:00
Kevin Newton 646a00892e [ruby/prism] Fix up clang-analyzer violations
https://github.com/ruby/prism/commit/259aef2acd
2024-04-16 14:30:34 +00:00
Kevin Newton 982dfa0793 [ruby/prism] Better error recovery for unwritable nodes
https://github.com/ruby/prism/commit/4828e73263
2024-04-16 13:32:59 +00:00
Kevin Newton 3c0756752c [ruby/prism] Better error message on statement inside argument list
https://github.com/ruby/prism/commit/3b1a99526a
2024-04-12 21:46:42 +00:00
Kevin Newton 1521af3259 [ruby/prism] Better error message on invalid def
https://github.com/ruby/prism/commit/d398e7d22c
2024-04-12 17:49:17 +00:00
Kevin Newton 52b862398d [ruby/prism] Syntax error for block argument on yield
https://github.com/ruby/prism/commit/9feeafbc67
2024-04-12 17:30:37 +00:00
Kevin Newton 0424c1fa7b [ruby/prism] Fix up embdoc lexing on EOF
https://github.com/ruby/prism/commit/8ee43be26d
2024-04-12 16:50:34 +00:00
Kevin Newton c41ecf3f47 [ruby/prism] Create the warning for unreachable statements
https://github.com/ruby/prism/commit/e17c86b886
2024-04-12 14:58:03 +00:00
Kevin Newton c553d34835 [ruby/prism] Warn void regardless of eval
https://github.com/ruby/prism/commit/48ba434fa4
2024-04-12 14:30:57 +00:00
Kevin Newton 8e514bedf9 [ruby/prism] Remove outdated comment
https://github.com/ruby/prism/commit/9adc88ddf8
2024-04-12 14:10:21 +00:00
Kevin Newton 4fc457e2b7 [ruby/prism] Implement the void statement warning
https://github.com/ruby/prism/commit/802ff71cd4
2024-04-12 14:10:20 +00:00
Kevin Newton abd05c848f
Sync latest prism 2024-04-12 09:52:29 -04:00
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