From: "jeremyevans0 (Jeremy Evans) via ruby-core" Date: 2023-04-04T04:30:11+00:00 Subject: [ruby-core:113101] [Ruby master Feature#19545] lp/hp logic parsing inconsistency Issue #19545 has been updated by jeremyevans0 (Jeremy Evans). hurricup (Alexandr Evstigneev) wrote in #note-3: > And any expression is a valid argument for any call. Just to be clear, while this may be a common belief, this is not the case. If you define valid expression to be a piece of Ruby code that could be executed by itself without a syntax error, then not all valid expressions are valid arguments in Ruby. The most obvious reason why not all valid expressions can be arguments is that some valid expressions contain `,`, which is used to separate arguments (e.g. multiple assignment). However, that isn't the only reason. From an CRuby internals perspective, all expressions (`expr`) are statements (`stmt`), and all statements surrounded by parentheses are primaries (`primary`), and all primaries are valid arguments (`arg`). Consult the `arg` definition in `parse.y` if you want to see what Ruby actually considers valid arguments. It may be possible to modify the parser to expand the definition of argument to start allowing certain expressions that are not currently supported as arguments. I think doing so would be a feature request and not a bug fix, since we would not consider backporting such changes. FWIW, modifying the current parser is challenging, at least for me. Hopefully with YARP, it will be easier. ---------------------------------------- Feature #19545: lp/hp logic parsing inconsistency https://bugs.ruby-lang.org/issues/19545#change-102636 * Author: hurricup (Alexandr Evstigneev) * Status: Open * Priority: Normal ---------------------------------------- As far as i get it, low precedence logic should behave the same as high precedence. But: This is ok: ``` puts(false || !false) ``` And this is not: ``` puts(false or not false) ``` Feels like in latter case there is some mess with comma precedence. -- 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/