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] decoding struct with i32 member results in cgen error: json: i32 is not struct #21161

Closed
revosw opened this issue Apr 1, 2024 · 0 comments · Fixed by #21162
Closed
Assignees
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@revosw
Copy link

revosw commented Apr 1, 2024

Describe the bug

x.json2 expects a type to be provided. When the type is a struct with an i32 field, the below error is output:

cgen error: json: i32 is not struct

Reproduction Steps

import json

pub struct StructA {
	kind string
	value string
}
pub struct StructB {
	kind string
	value i32
}

type StructSum = StructA | StructB

fn main() {
	// cgen error: json: i32 is not struct
	json.decode(StructSum, '{"kind": "Int32", value: 100}')!
}

Expected Behavior

json.decode successfully decodes the json into an instance of StructB

Current Behavior

cgen error: json: i32 is not struct

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.5 5da1fcc

Environment details (OS name and version, etc.)

V full version: V 0.4.5 4687f8c.5da1fcc
OS: windows, Microsoft Windows 11 Pro v22631 64-bit
Processor: 12 cpus, 64bit, little endian,

getwd: C:\dev\v\winmd
vexe: C:\dev_tools\v\v.exe
vexe mtime: 2024-04-01 17:34:15

vroot: OK, value: C:\dev_tools\v
VMODULES: OK, value: C:\Users\simen.vmodules
VTMP: OK, value: C:\Users\simen\AppData\Local\Temp\v_0

Git version: git version 2.40.0.windows.1
Git vroot status: weekly.2024.13-65-g5da1fcca
.git/config present: true

CC version: Error: 'cc' is not recognized as an internal or external command,
operable program or batch file.

thirdparty/tcc status: thirdparty-windows-amd64 a39eb79b

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.

@revosw revosw added the Bug This tag is applied to issues which reports bugs. label Apr 1, 2024
@revosw revosw changed the title [x.json2] decoding struct with i32 member results in cgen error: json: i32 is not struct [json] decoding struct with i32 member results in cgen error: json: i32 is not struct Apr 1, 2024
@Delta456 Delta456 self-assigned this Apr 1, 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants