Bug #15928
Updated by nobu (Nobuyoshi Nakada) over 3 years ago
The order of evaluation in constant declaration does not conform to JIS 3017:2013 11.4.2.2.3. # Problem Suppose that we are evaluating the following program. ```ruby ``` expr::C = rhs lhs ``` The standard seems to be requiring the following evaluation order: 1. expr * raise a `TypeError` TypeError if the value is not a kind of `Module` Module 2. rhs lhs 3. `rb_const_set(expr, rb_const_set(expr, :C, rhs)` lhs) However, the actual implementation evaluates in the following order 1. rhs lhs 2. expr 3. `rb_const_set(expr, rb_const_set(expr, :C, lhs)` lhs) * raise a `TypeError` TypeError if the expr is not a kind of `Module` Module # How to reproduce The next program does not raise "recv" but raises "value" ``` raise("recv")::C = raise("value") ``` The next program does not raise a `TypeError` TypeError but raises a `RuntimeError` RuntimeError ``` A = 1 A::C = raise("value") ``` # Question * Is this interpretation of the standard correct? * If it is, Should we change the current behavior? * If we shouldn't, does it mean an issue in the standard? c.f. * https://twitter.com/n0kada/status/1140234416175763456