Skip to content

new compiler: json.decode(...)! in main generates invalid C #28828

Description

@davlgd

Describe the bug

With the new compiler, calling json.decode with ! in main generates C that does not compile. The old compiler handles it fine. (I know json is deprecated in favour of json2, but it is still in vlib.)

Reproduction Steps

import json

struct Person {
	name string
}

fn main() {
	p := json.decode(Person, '{"name":"a"}')!
	println(p.name)
}

v -new-compiler run main.v

Expected Behavior

a

Current Behavior

The C compiler fails:

error: use of undeclared identifier 'Optional_main__Person'
error: use of undeclared identifier '__or_opt_0'

V version

V 0.5.2 4af2cb4 (-new-compiler). The old compiler I compare with is what -old-compiler runs, the V 0.5.2 release (7647ce1).

Environment details (OS name and version, etc.)

macOS 26.6, arm64, Apple clang 21

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions