Skip to content

fix Unknown quickjs tag: -6 error for long input strings#8

Open
robinvandernoord wants to merge 1 commit into
genotrance:mainfrom
robinvandernoord:main
Open

fix Unknown quickjs tag: -6 error for long input strings#8
robinvandernoord wants to merge 1 commit into
genotrance:mainfrom
robinvandernoord:main

Conversation

@robinvandernoord
Copy link
Copy Markdown

When I was using quickjs-ng to transpile some typescript into javascript, I ran into the following exception:

Traceback (most recent call last):
  File "/home/robin/werk/EW/quickjs-ng/breakstuff.py", line 66, in <module>
    print(ctx.eval(f"__transpile({source})"))
          ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Unknown quickjs tag: -6

Tag -6 corresponds to JS_TAG_STRING_ROPE, which is not currently handled in quickjs_to_python. This causes failures when QuickJS returns rope strings (e.g. from large template literals).

This PR adds handling for JS_TAG_STRING_ROPE by treating it the same as JS_TAG_STRING.

I've extracted my use-case as a replication using a silly large template literal here:
demo.py

After this change, the demo works and make test still passes.

// output of the demo.py script
    export function greet(name: string): string {
        return `Helloooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo, ${name}!`;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant