Skip to content

JS undefined from different contexts are not strictly equal to each other #12515

@lucas-mpc-brant

Description

@lucas-mpc-brant

Describe GraalVM and your environment :

  • GraalVM version or commit id if built from source: 21.0.4+8
  • CE or EE: EE
  • JDK version: 21.0.4
  • OS and OS Version: Linux (ubuntu 22.04.4)
  • Architecture: x86
  • The output of java -Xinternalversion:
 Java HotSpot(TM) 64-Bit Server VM (21.0.4+8-LTS-jvmci-23.1-b41) for linux-amd64 JRE (21.0.4+8-LTS-jvmci-23.1-b41), built on 2024-06-20T09:25:29Z by "buildslave" with gcc 11.2.0

Have you verified this issue still happens when using the latest snapshot?
No.

Describe the issue
We are having some trouble in regards to comparing values from different contexts. In this specific case both values are undefined from js, but we noticed that the receiver in the Value that came from another context is wrapped in a OtherContextGuestObject, and for this reason it seems to evaluate to false.

Code snippet or code repository that reproduces the issue

    @Test
    public void test() {
        final Source toBe = Source.create("js", """
		  function toBe(a , b){
		     return Object.is(a, b);
		  }
		  toBe
		""");


        final Source identical = Source.create("js", """
			  function toBe(a , b){
			     return a === b;
			  }
			  toBe
			""");

        final Context c1 = Context.create("js");
        final Context c2 = Context.create("js");

        final Value v1 = c1.eval("js", "undefined");
        final Value v2 = c2.eval("js", "undefined");


        Assertions.assertTrue(c1.eval(toBe).execute(v1, v2).asBoolean());
        Assertions.assertTrue(c1.eval(identical).execute(v1, v2).asBoolean());
    }

Steps to reproduce the issue
Run the junit test.

Expected behavior
I expected undefined from 2 different js contexts to be strictly equal to each other.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions