From: "mame (Yusuke Endoh) via ruby-core" Date: 2024-11-07T10:34:01+00:00 Subject: [ruby-core:119802] [Ruby master Bug#20785] Should `a in b, and c` `a in b, or c` `a in b, rescue c` be syntax ok? Issue #20785 has been updated by mame (Yusuke Endoh). Discussed at the dev meeting. Matz says that, in principle, the trailing comma of a pattern should be allowed. ```ruby a in b, and c # Prism should accept this as `(a in b,) and c` a in b, or c # Prism should accept this as `(a in b,) or c` ``` In terms of rescue after a comma, it should be handled as a modifier. ```ruby a in b, rescue c # (a in b,) rescue c ``` In terms of a newline after a comma, it should be handled as an end of a sentence. ```ruby a in b, # This line should be a complete sentence and c # This is an invalid line ``` However, if there are implementation difficulties with the parser, he would consider compromises. @yui-knk @kddnewton Do you think if matz's expectation is feasible? ---------------------------------------- Bug #20785: Should `a in b, and c` `a in b, or c` `a in b, rescue c` be syntax ok? https://bugs.ruby-lang.org/issues/20785#change-110486 * Author: tompng (tomoya ishida) * Status: Open * Assignee: matz (Yukihiro Matsumoto) * ruby -v: ruby 3.4.0dev (2024-10-04T03:22:53Z master 939ec9f080) +YJIT +MN +PRISM [arm64-darwin22] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- This code is accepted in parse.y but rejected in prism ~~~ruby tap do a in b, and c a in b, or c a in b, rescue c end # parsed as tap do (a in b,;) and c (a in b,;) or c a in b,; rescue c end ~~~ I think these should be rejected like prism (parse.y accepts) ~~~ruby a in b, and c a in b, and c tap do a in b, rescue c end ~~~ I think these should be accepted like parse.y (prism rejects) ~~~ruby tap do a in b, end tap do a in b, rescue end ~~~ -- 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/lists/ruby-core.ml.ruby-lang.org/