[#109095] [Ruby master Misc#18888] Migrate ruby-lang.org mail services to Google Domains and Google Workspace — "shugo (Shugo Maeda)" <noreply@...>
Issue #18888 has been reported by shugo (Shugo Maeda).
16 messages
2022/06/30
[ruby-core:108772] [Ruby master Feature#18159] Integrate functionality of dead_end gem into Ruby
From:
"nobu (Nobuyoshi Nakada)" <noreply@...>
Date:
2022-06-05 04:58:05 UTC
List:
ruby-core #108772
Issue #18159 has been updated by nobu (Nobuyoshi Nakada).
schneems (Richard Schneeman) wrote in #note-16:
> I am worried about the memory implications for enabling this by default. Is that a valid concern? If we are storing the contents of all files parsed in memory and are loading many files that will cause extra memory use I think.
Yes, I think it is a reasonable concern.
A problem is that gem_prelude code has no way to know the main script name currently.
> Overall the known compatibility issues with dead_end and Ruby 3.2 are currently:
>
> - Does not work with streaming code from STDIN (i.e. `echo 'def bad' | ruby` )
> - Monkeypatch not working with SyntaxError w/ streaming
> - Possible memory bloat with enabling SCRIPT_LINES__ by default to obtain streaming contents?
> - Does not work when executing a file directly (i.e. `ruby bad.rb`)
> - Monkeypatch not working with SyntaxError w/ direct file running
> - Cannot get source code
> - Does not work with eval
> - Monkeypatch not working w/ eval
> - Cannot get source code
> - Does not work with ruby `-e` command.
> - Monekeypatch does not work with `-e`
> - Cannot get source code
Monkeypatch not working with main script (including streaming and `-e`) is an identical issue.
In these cases, the parser outputs error messages directly not using normal exception handling.
The following patch just shows how to keep the source lines and to call `detailed_message`.
```diff
diff --git a/ruby.c b/ruby.c
index 884028daa02..4a748dbe72a 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1997,6 +1997,10 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
rb_parser_set_context(parser, 0, TRUE);
+ if (opt->features.set & FEATURE_BIT(dead_end)) {
+ rb_parser_keep_script_lines(parser);
+ }
+
if (opt->e_script) {
VALUE progname = rb_progname;
rb_encoding *eenc;
@@ -2050,6 +2054,13 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt)
rb_stdio_set_default_encoding();
if (!ast->body.root) {
+ if (opt->features.set & FEATURE_BIT(dead_end)) {
+ VALUE exc = rb_errinfo();
+ VALUE opt = rb_hash_new();
+ VALUE rb_get_detailed_message(VALUE exc, VALUE opt);
+ rb_hash_aset(opt, ID2SYM(rb_intern_const("highlight")), RBOOL(rb_stderr_tty_p()));
+ rb_write_error_str(rb_get_detailed_message(exc, opt));
+ }
rb_ast_dispose(ast);
return Qfalse;
}
```
----------------------------------------
Feature #18159: Integrate functionality of dead_end gem into Ruby
https://bugs.ruby-lang.org/issues/18159#change-97837
* Author: duerst (Martin D端rst)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 3.1
----------------------------------------
Missing 'end' errors are difficult to fix. We should integrate the functionality of the dead_end gem (https://github.com/zombocom/dead_end) into Ruby similar to how we integrated did_you_mean. It would greatly help programming Ruby, in particular for beginners.
See also Ruby Kaigi Takeout 2021 talk by Richard Schneeman https://rubykaigi.org/2021-takeout/presentations/schneems.html.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>