v icon indicating copy to clipboard operation
v copied to clipboard

[Compiler Bug] json encode map

Open russo-2025 opened this issue 2 years ago • 0 comments

Describe the bug

module main

import json

struct User {
	name string
}

struct MyStruct {
	user	&User // ok
	users	map[string]User // ok
	users2	map[string]&User // err
}

fn main() {
	user := User{
		name: "foo"
	}
	data := MyStruct{
		user: &user
		users: { "keyfoo": user}
		users2: { "keyfoo": &user}
	}
	
	println(json.encode(data))
}

Expected Behavior

ok

Current Behavior

==================
C:/Users/russo/AppData/Local/Temp/v_0/jsonbug.6181760396250080387.tmp.c:499: warning: WINVER redefined
C:/Users/russo/AppData/Local/Temp/v_0/jsonbug.6181760396250080387.tmp.c:2528: error: identifier expected
...
==================
(Use `v -cg` to print the entire error message)

builder error:
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang

Reproduction Steps

v run jsonbug.v

V version

V 0.3.3 b2a71ec

Environment details (OS name and version, etc.)

OS: windows, Microsoft Windows 10 Pro v19042 64-bit Processor: 16 cpus, 64bit, little endian, CC version: Error: exec failed (CreateProcess) with code 2: Не удается найти указанный файл. cmd: cc --version

getwd: C:\Users\russo\Desktop vmodules: C:\Users\russo.vmodules vroot: D:_dev\v_lang vexe: D:_dev\v_lang\v.exe vexe mtime: 2023-03-12 10:35:36 is vroot writable: true is vmodules writable: true V full version: V 0.3.3 b2a71ec

Git version: git version 2.35.3.windows.1 Git vroot status: weekly.2023.10-39-gb2a71eca (1 commit(s) behind V master) .git/config present: true thirdparty/tcc status: thirdparty-windows-amd64 e90c2620

russo-2025 avatar Mar 12 '23 11:03 russo-2025