Skip to content

str.runes() fails on the JavaScript backend #20500

@justinas

Description

@justinas

Describe the bug

The runes() method call crashes in code generated by the JS backend.

Reproduction Steps

foo := "hello🎅".runes()
println(foo)

Expected Behavior

Expected both C and JS backends to produce the same output.

Current Behavior

$ v run runes.v    # runs okay
[`h`, `e`, `l`, `l`, `o`, `🎅`]
$ v -o runes.js runes.v && node runes.js
/home/justinas/vlang-testcases/runes.js:3963
                                let r = new rune(new u8('0')); r = new rune(s.str[i.val].charCodeAt())
                                                                                         ^

TypeError: Cannot read properties of undefined (reading 'charCodeAt')
    at string_runes (/home/justinas/vlang-testcases/runes.js:3963:62)
    at js_main (/home/justinas/vlang-testcases/runes.js:6022:15)
    at /home/justinas/vlang-testcases/runes.js:6079:25

Node.js v18.18.2

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.4 ac2dcc2

Environment details (OS name and version, etc.)

NixOS 23.11 (Tapir)

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.Unit: JSBugs/feature requests, that are related to the JavaScript backend.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions