Skip to content

jsgen: maps created on the fly do not have a valid size #24616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gchumillas opened this issue May 30, 2025 · 1 comment · Fixed by #24620
Closed

jsgen: maps created on the fly do not have a valid size #24616

gchumillas opened this issue May 30, 2025 · 1 comment · Fixed by #24620
Labels
Bug This tag is applied to issues which reports bugs. Unit: JS Bugs/feature requests, that are related to the JavaScript backend.

Comments

@gchumillas
Copy link
Contributor

gchumillas commented May 30, 2025

Describe the bug

Maps created on the fly do not have a valid size.

Reproduction Steps

Create a small main.v app:

fn main() {
	mut m := {'one': 1, 'two': 2}
	assert m.len == 2

	/* However, this works!
	
	mut m := map[string]int{}
	m['one'] = 1
	m['two'] = 2
	assert m.len == 2 */
}

Compile and execute it:

v -b js main.v
node main.js

Output:

FAIL: fn main.main(): assert m.len == 2

Expected Behavior

You should not complain.

Current Behavior

It complains.

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.10 0d00eb7

Environment details (OS name and version, etc.)

V full version V 0.4.10 52c7130.0d00eb7
OS macos, macOS, 15.5, 24F74
Processor 8 cpus, 64bit, little endian, Apple M1 Pro
Memory 0.53GB/16GB
V executable /Users/gonzalo/Projects/Personal/vlang/v
V last modified time 2025-05-30 11:52:55
V home dir OK, value: /Users/gonzalo/Projects/Personal/vlang
VMODULES OK, value: /Users/gonzalo/.vmodules
VTMP OK, value: /tmp/v_501
Current working dir OK, value: /Users/gonzalo/Projects/Personal/vlang
Git version git version 2.39.1
V git status weekly.2025.22-20-g0d00eb71
.git/config present true
cc version Apple clang version 17.0.0 (clang-1700.0.13.5)
gcc version Apple clang version 17.0.0 (clang-1700.0.13.5)
clang version Apple clang version 17.0.0 (clang-1700.0.13.5)
tcc version tcc version 0.9.28rc 2024-02-05 HEAD@105d70f7 (AArch64 Darwin)
tcc git status thirdparty-macos-arm64 e447816c
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.

@gchumillas gchumillas added the Bug This tag is applied to issues which reports bugs. label May 30, 2025
Copy link

Connected to Huly®: V_0.6-22977

@gchumillas gchumillas changed the title jsgen: maps created on the fly do not have a valid size. jsgen: maps created on the fly do not have a valid size May 30, 2025
@felipensp felipensp added the Unit: JS Bugs/feature requests, that are related to the JavaScript backend. label May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Unit: JS Bugs/feature requests, that are related to the JavaScript backend.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants