Skip to content

[interop] Cannot use foreign objects as keys in Hash due to #hash NameError #2138

Open
@fniephaus

Description

@fniephaus

Looks like foreign objects do not expose #hash? I think it should be provided through InteropLibrary's identityHashCode.

Repro Session

$ polyglot --jvm --shell
GraalVM MultiLanguage Shell 21.0.0-dev
Copyright (c) 2013-2020, Oracle and/or its affiliates
  JavaScript version 21.0.0-dev
  Python version 3.8.5
  R version 3.6.1
  Ruby version 2.6.6
ruby> x = {}
{}
ruby> x[Object.new] = true
true
ruby> x.keys
[#<Object:0x250>]
ruby> x[Polyglot.eval('python', 'object()')] = true
Unknown identifier: hash (NameError)
        at <ruby> <top (required)>(resource:/truffleruby/core/truffle/boot.rb:16:15-59)
        at <ruby> null(Unknown)

Metadata

Metadata

Assignees

No one assigned

    Labels

    polyglotUses multiple Truffle languages or host interop

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions