[#106355] [Ruby master Bug#18373] RBS build failure: '/include/x86_64-linux/ruby/config.h', needed by 'constants.o'. — "vo.x (Vit Ondruch)" <noreply@...>
Issue #18373 has been reported by vo.x (Vit Ondruch).
28 messages
2021/12/01
[ruby-core:106497] [Ruby master Bug#18385] Refinement#import_methods(Enumerable) doesn't work
From:
"shugo (Shugo Maeda)" <noreply@...>
Date:
2021-12-06 00:35:47 UTC
List:
ruby-core #106497
Issue #18385 has been updated by shugo (Shugo Maeda).
Status changed from Open to Assigned
Eregon (Benoit Daloze) wrote in #note-1:
> It means you can't import methods defined in C, only methods defined with Ruby code.
> Methods need to be defined in Ruby code to be affected by refinements (e.g. other refinements in that `refine` block or under `M`).
> So for example this wouldn't work if you define `each` inside `refine String do` since those C methods wouldn't know how to find `each` with refinements (e.g., they use `rb_funcall` which doesn't know about refinements).
> (it would work on Ruby implementations where Enumerable is defined in Ruby code, interestingly)
>
> @shugo WDYT?
Yes, it's an implementation issue.
> I think we should improve the error message, like:
> `Can't import method which is not defined with Ruby code: Comparable#between?`
Thank you. I'll fix the error message.
zverok (Victor Shepelev) wrote in #note-2:
> Yeah, at least the message should be clearer.
>
> I didn't realize that `import_methods` is a make-believe feature, not really integrated with the interpreter/object model.
>
> Are there any plans to integrate it more tightly, with refinements being "visible" to C code?..
Currently I have no plan and afraid that it may bring another implementation difficulty.
----------------------------------------
Bug #18385: Refinement#import_methods(Enumerable) doesn't work
https://bugs.ruby-lang.org/issues/18385#change-95153
* Author: zverok (Victor Shepelev)
* Status: Assigned
* Priority: Normal
* Assignee: shugo (Shugo Maeda)
* Backport: 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
Very simple to reproduce:
```ruby
module M
refine String do
import_methods Enumerable
end
end
```
Leads to: `import_methods': Can't import method: Enumerable#drop (ArgumentError)`
Which, grepping through code, seems to be raised [here](https://github.com/ruby/ruby/blob/master/eval.c#L1529) but I am not versed enough in Ruby internals to debug further.
An attempt to `import_methods Comparable` leads to the same problem, BTW: `Can't import method: Comparable#between?`
Am I missing something crucial about `import_method` behavior?
--
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>