From: shyouhei@...
Date: 2020-12-18T03:45:56+00:00
Subject: [ruby-core:101504] [Ruby master Feature#17397] `shareable_constant_value: literal` should check at runtime, not at parse time

Issue #17397 has been updated by shyouhei (Shyouhei Urabe).


marcandre (Marc-Andre Lafortune) wrote:
> I think `shareable_constant_value: literal` is too strict because it has too crude checks at parse time.

This is true.  Current restriction is very conservative not to break things (See #17273 for the background).  If we can gain safety and usability at once, I think it's OK to relax.  But experimental_everything is too lax (-1 for nobu's comment).  There must be a better safety-usability trade-off than that.  This pragma must not be an all-or-nothing flag I believe.

----------------------------------------
Feature #17397: `shareable_constant_value: literal` should check at runtime, not at parse time
https://bugs.ruby-lang.org/issues/17397#change-89284

* Author: marcandre (Marc-Andre Lafortune)
* Status: Open
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
----------------------------------------
I think `shareable_constant_value: literal` is too strict because it has too crude checks at parse time.

I wish the following code would parse and run:

```ruby
# shareable_constant_value: literal

class Foo < RuntimeError
end

# Similar code, but does not parse:
Bar = Class.new(RuntimeError) # => unshareable expression

Baz = Ractor.make_shareable(anything_here) # => unshareable expression

Qux = Set[1, 2, 3].freeze # => unshareable expression
```

Could we instead raise some sort of RuntimeError when an assignment is made that is not shareable?



-- 
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>