Skip to content

webassembly: getting JS symbols implicitly also throws errors #17657

@WebReflection

Description

@WebReflection

Port, board and/or hardware

webassembly

MicroPython version

MicroPython webassembly latest from npm

Reproduction

In here we solved the in operation check #17604 but if any libraries tries to read the stringified version of a reference we have the same issue via the get proxy trap.

function test(value) {
  return Object.prototype.toString.call(value);
}
import js
js.test({})

Result:

RuntimeError: Aborted(Assertion failed: stringToUTF8Array expects a string (got symbol))

Expected behaviour

We covered Symbol.iterator we should cover also Symbol.toStringTag as that's implicitly retrieved when Object.prototype.toString.call(ref) happens, which is a very common way to retrieve the kind of the reference as it returns:

  • [object Object]
  • [object Array]
  • [object Null]
  • [object Function]
  • [object Anything]

This practice is particularly useful when unknown kinds are around and any serializer would like to guess how to handle these, and it's currently breaking a specific PyScript use case which is also pretty common when used in IoT contrained environments.

Observed behaviour

An error is throws every single time.

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy