v icon indicating copy to clipboard operation
v copied to clipboard

bug: C error instead of clean compile or V error

Open snakeru opened this issue 7 months ago • 4 comments

V version: V 0.4.10 27829d5, press to see full `v doctor` output
V full version V 0.4.10 27829d56cd897ed1eb25638d0b113320a24e7768.27829d5
OS linux, Ubuntu 22.04.5 LTS
Processor 16 cpus, 64bit, little endian, 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
Memory 21.87GB/31.13GB
V executable /home/a/git/v/v
V last modified time 2025-05-11 08:09:22
V home dir OK, value: /home/a/git/v
VMODULES OK, value: /home/a/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/a/projects/iverlet
Git version git version 2.34.1
V git status weekly.2025.19-14-g27829d56
.git/config present true
cc version cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
gcc version gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
clang version N/A
tcc version tcc version 0.9.28rc 2025-02-13 HEAD@f8bd136d (x86_64 Linux)
tcc git status thirdparty-linux-amd64 696c1d84
emcc version N/A
glibc version ldd (Ubuntu GLIBC 2.35-0ubuntu3.9) 2.35

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

module main

type Aa = [2]struct{}

fn main() {
    a := [2]Aa{}
    _ = a
}

What did you see?

================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/main.01JTZTD4SHHR8VG40GTDZSA62V.tmp.c:1052: error: ';' expected (got "Array_fixed_main__Aa_2")
=================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
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 .

What did you expect to see?

I expect this code to compile or at least provide me with a helpful error description. This is the minimal example that throws that error, somewhat more elaborate (that I actually wanted to use) is:

module main
struct Ab {
	data    int
}
type Cd = [2]Ab
type Ef = [2]Cd
fn main() {
	println(1)
}

[!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.

snakeru avatar May 11 '25 14:05 snakeru

Connected to Huly®: V_0.6-22832

huly-for-github[bot] avatar May 11 '25 14:05 huly-for-github[bot]

This needs to be an error as you can't make nested type aliases.

Delta456 avatar May 11 '25 18:05 Delta456

Ah, a pity that one isn't allowed to nest type aliases. When writing programs I still think in pure Go and then translate it to V to see what breaks. But in Go these are real types, not aliases.

That aside, the code in the very first snippet doesn't use nested aliases but still breaks.

snakeru avatar May 12 '25 05:05 snakeru

It should works, once normal array works. []struct{}.

felipensp avatar May 12 '25 12:05 felipensp