Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Interop] Array#swap invocable, but not readable #1816

Closed
fniephaus opened this issue Nov 20, 2019 · 2 comments
Closed

[Interop] Array#swap invocable, but not readable #1816

fniephaus opened this issue Nov 20, 2019 · 2 comments
Assignees

Comments

@fniephaus
Copy link
Member

I'm getting errors when trying to display the API of an Array, because of Array#swap. It's listed as part of getMembers and can be invoked. But it does not seem to be a readable member. I'm not too familiar with the API of Array, but I couldn't find #swap in the class documentation, so it may be TruffleRuby-specific.

Repro session

$ polyglot --shell --jvm
GraalVM MultiLanguage Shell 19.3.0
Copyright (c) 2013-2019, Oracle and/or its affiliates
  Python version 3.7.4
  Ruby version 2.6.2
python> import polyglot
python> x = polyglot.eval(language='ruby', string='[1, 2]')
python> [key for key in dir(x) if not hasattr(x, key)]
['swap'] # EMPTY LIST EXPECTED
python> x.swap(0,1)
1
python> x
[2, 1] # WORKED AS EXPECTED
@eregon
Copy link
Member

eregon commented Nov 21, 2019

Thank you for the bug report, I can reproduce.
Array#swap is indeed an internal method, marked as protected.
protected is between public and private and that's probably why it appears in one case but not the other.

@pitr-ch Could you take a look at this?

I think there are two things to fix:

  • Should protected methods be listed in getMembers() and isMemberReadable()? We need to be consistent.
  • We should probably hide Array#swap, private + Truffle.privately {} or better Truffle::ArrayOperations.swap.

@eregon eregon added the bug label Nov 21, 2019
@pitr-ch pitr-ch self-assigned this Nov 21, 2019
@pitr-ch
Copy link
Contributor

pitr-ch commented Dec 2, 2019

fixed in 25b684e

@pitr-ch pitr-ch closed this as completed Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants