Skip to content
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

json: not parsing embedded struct with also embedded structs #22273

Closed
esquerbatua opened this issue Sep 21, 2024 · 0 comments · Fixed by #22277
Closed

json: not parsing embedded struct with also embedded structs #22273

esquerbatua opened this issue Sep 21, 2024 · 0 comments · Fixed by #22277
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Modules: JSON Bugs/feature requests, that are related to `json` and `x.json2` modules. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.

Comments

@esquerbatua
Copy link
Contributor

esquerbatua commented Sep 21, 2024

Describe the bug

json module it's not parsing fields of various levels of embedded structs

Reproduction Steps

module main

import json

struct Json3 {
	embed f64
}

struct Json2 {
	Json3
	inner []f64
}

struct Json {
	Json2
	test f64
}

fn main() {
	str:= '{"inner": [1, 2, 3, 4, 5],"test": 1.0, "embed": 2.0}'
	data := json.decode(Json, str) or {
		eprintln('Failed to decode json, error: ${err}')
		return
	}
	println(data)
	assert data.inner.len == 5
	assert data.inner[0] == 1.0
	assert data.inner[4] == 5.0
	assert data.test == 1.0
	assert data.embed == 2.0
}

Expected Behavior

Run correctly, with all of the data parsed

Current Behavior

/tmp/v_1000/break.tmp.c:2325: error: field not found: Json3
builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .
make: *** [Makefile:11: run] Error 1

Possible Solution

No response

Additional Information/Context

No response

V version

V full version: V 0.4.7 5e624a5

Environment details (OS name and version, etc.)

V full version: V 0.4.7 5e624a5
OS: linux, Ubuntu 24.04.1 LTS
Processor: 16 cpus, 64bit, little endian, AMD Ryzen 7 7840HS w/ Radeon 780M Graphics

getwd: /home/esquerbatua/git/breakV
vexe: /home/esquerbatua/git/v/v
vexe mtime: 2024-09-21 15:56:29

vroot: OK, value: /home/esquerbatua/git/v
VMODULES: OK, value: /home/esquerbatua/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.43.0
Git vroot status: weekly.2024.37-35-g5e624a5b
.git/config present: true

CC version: cc (Ubuntu 13.2.0-23ubuntu4) 13.2.0
thirdparty/tcc status: thirdparty-linux-amd64 0134e9b9

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.

@esquerbatua esquerbatua added the Bug This tag is applied to issues which reports bugs. label Sep 21, 2024
@felipensp felipensp added the Modules: JSON Bugs/feature requests, that are related to `json` and `x.json2` modules. label Sep 21, 2024
@felipensp felipensp self-assigned this Sep 21, 2024
@spytheman spytheman added the Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. label Sep 22, 2024
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. Modules: JSON Bugs/feature requests, that are related to `json` and `x.json2` modules. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants