Kevin Newton
59f931e4f7
[PRISM] Remove dummy_line_node usage for PM_BACK_REFERENCE_READ_NODE
2024-04-04 14:14:55 -04:00
Kevin Newton
6c1cf5232f
[PRISM] Remove dummy_line_node usage in pm_interpolated_node_compile
2024-04-04 14:14:55 -04:00
Kevin Newton
ced6aff206
[PRISM] Mark constant path owning expressions as not popped
2024-04-03 17:34:12 -04:00
Kevin Newton
8191735b73
[PRISM] Fix BEGIN{} execution order
2024-03-29 08:51:04 -04:00
Kevin Newton
a8f902ea8e
[PRISM] Add debug info for frozen strings
2024-03-28 15:17:29 -04:00
Kevin Newton
86e0d83a32
[PRISM] Simplify raising load errors
2024-03-28 12:04:35 -04:00
Kevin Newton
f7c5e11d89
[PRISM] Use new -x prism API
2024-03-28 12:04:35 -04:00
Kevin Newton
7e12b03c5a
[PRISM] Set path on syntax error
2024-03-27 17:19:24 -04: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
ab2ee308aa
[PRISM] Match style for invalid encoding error
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
a69f0047cb
[PRISM] Use new error formatting API
2024-03-27 13:03:11 -04:00
Kevin Newton
42d1cd8f7f
[PRISM] Pass --enable-frozen-string-literal through to evals
2024-03-27 08:34:42 -04:00
Kevin Newton
e4b2109065
[PRISM] Fix ASCII-compatible check for eval encoding
2024-03-27 08:34:42 -04:00
Kevin Newton
0c62eb25b5
[PRISM] Use correct encoding for regular expression literals
2024-03-26 15:32:09 -04:00
Kevin Newton
4300c42a7e
[PRISM] Better handle interpolated* nodes with inner frozen parts
2024-03-26 12:11:09 -04:00
Étienne Barrié
12be40ae6b
Implement chilled strings
...
[Feature #20205 ]
As a path toward enabling frozen string literals by default in the future,
this commit introduce "chilled strings". From a user perspective chilled
strings pretend to be frozen, but on the first attempt to mutate them,
they lose their frozen status and emit a warning rather than to raise a
`FrozenError`.
Implementation wise, `rb_compile_option_struct.frozen_string_literal` is
no longer a boolean but a tri-state of `enabled/disabled/unset`.
When code is compiled with frozen string literals neither explictly enabled
or disabled, string literals are compiled with a new `putchilledstring`
instruction. This instruction is identical to `putstring` except it marks
the String with the `STR_CHILLED (FL_USER3)` and `FL_FREEZE` flags.
Chilled strings have the `FL_FREEZE` flag as to minimize the need to check
for chilled strings across the codebase, and to improve compatibility with
C extensions.
Notes:
- `String#freeze`: clears the chilled flag.
- `String#-@`: acts as if the string was mutable.
- `String#+@`: acts as if the string was mutable.
- `String#clone`: copies the chilled flag.
Co-authored-by: Jean Boussier <byroot@ruby-lang.org>
2024-03-19 09:26:49 +01:00
Kevin Newton
b7ca4b1e2d
[PRISM] Fix up frozen checks for aref
2024-03-18 11:55:43 -04:00
Jean Boussier
91bf7eb274
Refactor frozen_string_literal check during compilation
...
In preparation for https://bugs.ruby-lang.org/issues/20205 .
The `frozen_string_literal` compilation option will no longer
be a boolean but a tri-state: `on/off/default`.
2024-03-15 15:52:33 +01:00
Kevin Newton
b4f3f3c103
[PRISM] Fix up source file when not frozen
2024-03-15 09:47:49 -04:00
Kevin Newton
043c90e161
Fix compiling shareable constant nodes
2024-03-15 09:42:44 -04:00
Kevin Newton
1e7c0fcc9a
[PRISM] Fix float in case dispatch
2024-03-14 21:59:26 -04:00
Jean Boussier
09d8c99cdc
Ensure test suite is compatible with --frozen-string-literal
...
As preparation for https://bugs.ruby-lang.org/issues/20205
making sure the test suite is compatible with frozen string
literals is making things easier.
2024-03-14 17:56:15 +01:00
Kevin Newton
2f8cbd6431
[PRISM] Handle ambiguous_param0 for it and numbered parameters
2024-03-13 19:01:33 -04:00
Kevin Newton
7c9e6eab89
Handle nth ref too big
2024-03-13 19:01:21 -04:00
Kevin Newton
fa009e392c
[PRISM] Static literal strings should be fstrings
2024-03-13 14:24:53 -04:00
Kevin Newton
e6a1baad48
[PRISM] Fix compiling duplicated keywords
2024-03-13 14:13:19 -04:00
Kevin Newton
22217e70c2
[PRISM] Handle parentheses in patterns in prism
2024-03-13 10:06:19 -04:00
Kevin Newton
a6dac9bb4f
[PRISM] Parse stdin on CLI with prism
2024-03-11 12:51:32 -04:00
Kevin Newton
811296b4af
[PRISM] Use new integer logic
2024-03-07 18:02:33 -05: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
a29c0e827f
[PRISM] Handle implicit flip-flop bounds checking against $.
2024-02-28 13:26:00 -05:00
Kevin Newton
16c7144cd5
[PRISM] Only look up encoding once per file
2024-02-28 12:44:24 -05:00
Kevin Newton
f8355e88d6
[PRISM] Do not load -r until we check if main script can be read
2024-02-28 12:42:57 -05:00
Kevin Newton
4016535404
[PRISM] Integrate new number parsing
2024-02-22 22:42:44 -05:00
Kevin Newton
be96dc9f8c
[PRISM] Support it local variable
2024-02-21 17:55:11 -05:00
Kevin Newton
5c02d97780
[PRISM] Remove more dummy line usage
...
* or
* optional parameter
* parentheses
* pre execution
* post execution
* range
* rational
* redo
2024-02-21 14:14:21 -05:00
Kevin Newton
e19fde52cc
[PRISM] Remove more dummy line usage
...
* if
* unless
2024-02-21 14:14:21 -05:00
Kevin Newton
e1f6b477e0
[PRISM] Remove more dummy line usage
...
* regular expressions
* rescue
* rescue modifier
2024-02-21 14:14:21 -05:00
Kevin Newton
e7d480df5d
[PRISM] Remove more dummy line usage
...
* returns
* retry
* self
* singleton class
2024-02-21 14:14:21 -05:00
Kevin Newton
61c5936da3
[PRISM] Remove more dummy line usage
...
* source files
* source encodings
* source lines
2024-02-21 14:14:21 -05:00
Kevin Newton
220ced7486
[PRISM] Remove more dummy line usage
...
* yields
* xstrings
* while
* until
* undef
* true
* symbol
* super
* string
* statements
* splat
2024-02-21 14:14:21 -05:00
Peter Zhu
777c4da0bf
[PRISM] GC guard strings
...
Using RSTRING_PTR can cause the string object to not exist on the stack,
which could cause it to be GC'd or be moved by GC compaction. This can
cause RSTRING_PTR to point to the incorrect location if the string is
embedded and moved by GC compaction.
Fixes ruby/prism#2442 .
2024-02-16 15:02:03 -05:00
Kevin Newton
9933377c34
[PRISM] Correctly hook up line numbers for eval
2024-02-14 15:29:26 -05:00
Kevin Newton
fc2c128e7e
[PRISM] Set eval encoding based on string encoding
2024-02-14 13:24:43 -05:00
Matt Valentine-House
f70a4a0336
[PRISM] yield is invalid inside eval
2024-02-13 21:19:12 -05:00
Matt Valentine-House
0285b533e9
[PRISM] Don't rb_bug if redo/break/next used during eval
2024-02-13 21:19:12 -05:00
Peter Zhu
a5869e5d8c
[PRISM] Replace assert with RUBY_ASSERT
...
assert does not print the bug report, only the file and line number of
the assertion that failed. RUBY_ASSERT prints the full bug report, which
makes it much easier to debug.
2024-02-13 15:54:04 -05:00
Peter Zhu
83c158fdfc
[PRISM] Replace assert with rb_bug
2024-02-13 15:54:04 -05:00
Kevin Newton
4e481c772e
[PRISM] Refactors to use more locations
2024-02-13 10:26:42 -05:00