Skip to content

jsgen: backend cannot transpile the built-in values() function #24209

@gchumillas

Description

@gchumillas

Describe the bug

The JS backend cannot transpile the builtin values() function.

Reproduction Steps

Create a small V file containing the following code

// main.v
module main

fn main() {
	items := {
		1: 'one'
		2: 'two'
		3: 'three'
	}

	println(items.values())
}

And a small HTML file:

// index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>V Web Example</title>
</head>
<body>
    <div id="app"></div>
    
    <!-- The compiled JavaScript will be included here -->
    <script src="main.js"></script>
</body>
</html>

And then transpile it to JavaScript and open the browser:

v -b js_browser main.v & open index.html

See the log errors in your browser:

main.js:6373 Uncaught (in promise) ReferenceError: Map_int_string_values is not defined
    at js_main (main.js:6373:3)
    at main.js:6429:25

Expected Behavior

Be able to transpile the built-in values() function.

Current Behavior

It can't.

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.10 d559a62

Environment details (OS name and version, etc.)

V full version V 0.4.10 30ececc.d559a62
OS macos, macOS, 15.3.2, 24D81
Processor 8 cpus, 64bit, little endian, Apple M1 Pro
Memory 0.72GB/16GB
V executable /Users/gonzalo/v/v
V last modified time 2025-04-13 10:51:40
V home dir OK, value: /Users/gonzalo/v
VMODULES OK, value: /Users/gonzalo/.vmodules
VTMP OK, value: /tmp/v_501
Current working dir OK, value: /Users/gonzalo/Projects/Personal/v/rx/examples/example_2
Git version git version 2.39.1
V git status weekly.2025.14-39-gd559a62c (3 commit(s) behind V master)
.git/config present true
cc version Apple clang version 17.0.0 (clang-1700.0.13.3)
gcc version Apple clang version 17.0.0 (clang-1700.0.13.3)
clang version Apple clang version 17.0.0 (clang-1700.0.13.3)
tcc version tcc version 0.9.28rc 2024-02-05 HEAD@105d70f7 (AArch64 Darwin)
tcc git status thirdparty-macos-arm64 713692d4
emcc version N/A
glibc version N/A

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

    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