From: "Dan0042 (Daniel DeLorme) via ruby-core" Date: 2024-02-06T18:46:59+00:00 Subject: [ruby-core:116606] [Ruby master Feature#20235] Deprecate CHAR syntax Issue #20235 has been updated by Dan0042 (Daniel DeLorme). I agree, it would be good to fix the parsing. At least that's as a bugfix that can be done now. In the long term I think warning about char literals would also be a good thing. Because I stumbled on a problem with `p $stdin.closed?=>true` its make me a bit paranoid about what other problems might be there because of char literals, hidden? Regarding `p $stdin.raw!=>true` that's not related to char literals but I think it should be fixed also. Maybe: ```diff diff --git a/parse.y b/parse.y --- a/parse.y +++ b/parse.y @@ -10657,7 +10657,7 @@ parse_ident(struct parser_params *p, int c, int cmd_state) if (tokadd_mbchar(p, c) == -1) return 0; c = nextc(p); } while (parser_is_identchar(p)); - if ((c == '!' || c == '?') && !peek(p, '=')) { + if (c == '?' || (c == '!' && (!peek(p, '=') || peek_n(p, '>', 1) || peek_n(p, '=', 1) || peek_n(p, '~', 1)))) { result = tFID; tokadd(p, c); } ``` ---------------------------------------- Feature #20235: Deprecate CHAR syntax https://bugs.ruby-lang.org/issues/20235#change-106618 * Author: Dan0042 (Daniel DeLorme) * Status: Open * Priority: Normal ---------------------------------------- I propose deprecating the `?c` syntax. It served a purpose in ruby <= 1.8, but no longer. The reason I'm proposing this is because today I ran into this error: ```ruby p $stdin.closed?=>true # comparison of String with true failed (ArgumentError) ``` I was completed mystified, and had to resort to Ripper to figure out what's going on ``` p *Ripper.lex("p $stdin.closed?=>true") [[1, 0], :on_ident, "p", CMDARG] [[1, 1], :on_sp, " ", CMDARG] [[1, 2], :on_gvar, "$stdin", END] [[1, 8], :on_period, ".", DOT] [[1, 9], :on_ident, "closed", ARG] [[1, 15], :on_CHAR, "?=", END] #OOOOHH!!!!! [[1, 17], :on_op, ">", BEG] [[1, 18], :on_kw, "true", END] ``` We don't have to commit to a removal schedule right now, but I think it would at least be good to print a deprecation message if $VERBOSE. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/