Skip to content

cgen error for an if expression, with a panic() call in the else branch, assigned to a ?string variable #22467

@spytheman

Description

@spytheman

V doctor:

V full version: V 0.4.8 7565841.72b4804
OS: linux, Ubuntu 20.04.6 LTS
Processor: 2 cpus, 64bit, little endian, Intel(R) Core(TM) i3-3225 CPU @ 3.30GHz

getwd: /space/v/oo
vexe: /space/v/oo/v
vexe mtime: 2024-10-10 01:31:53

vroot: OK, value: /space/v/oo
VMODULES: OK, value: /home/delian/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.46.0
Git vroot status: 0.4.8-75-g72b48047
.git/config present: true

CC version: cc (Ubuntu 10.5.0-1ubuntu1~20.04) 10.5.0
thirdparty/tcc status: thirdparty-linux-amd64 0134e9b9

What did you do?
./v -g -o vdbg cmd/v && ./vdbg x.v

mut x := ?string(none)
x = if true {
	''
} else {
	panic('')
}
println(x)

What did you expect to see?

a compiled program

What did you see instead?

================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/x.01J9T0VW2FV63VCS5NVGQ8NEYN.tmp.c:13450: error: declaration of an array of incomplete type elements
=================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.Unit: CompilerBugs/feature requests, that are related to the V compiler in general.Unit: cgenBugs/feature requests, that are related to the default C generating backend.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions