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

cgen error on sizeof call with matching array type of sumtype #23768

Open
gechandesu opened this issue Feb 20, 2025 · 2 comments · May be fixed by #23787
Open

cgen error on sizeof call with matching array type of sumtype #23768

gechandesu opened this issue Feb 20, 2025 · 2 comments · May be fixed by #23787
Assignees
Labels
Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.

Comments

@gechandesu
Copy link
Contributor

gechandesu commented Feb 20, 2025

V version: V 0.4.9 cfeb1bb, press to see full `v doctor` output
V full version V 0.4.9 5ec9bb5.cfeb1bb
OS linux, Linux version 6.6.8-arch1-1 (linux@archlinux) (gcc (GCC) 13.2.1 20230801, GNU ld (GNU Binutils) 2.41.0) #1 SMP PREEMPT_DYNAMIC Thu, 21 Dec 2023 19:01:01 +0000
Processor 16 cpus, 64bit, little endian, 12th Gen Intel(R) Core(TM) i5-1240P
Memory 0.71GB/15.35GB
V executable /home/ge/.vlang/v
V last modified time 2025-02-20 07:30:30
V home dir OK, value: /home/ge/.vlang
VMODULES OK, value: /home/ge/.vmodules
VTMP OK, value: /tmp/v_1000
Current working dir OK, value: /home/ge/Code/v/zmq
Git version git version 2.48.1
V git status weekly.2025.08-15-gcfeb1bb5
.git/config present true
cc version cc (GCC) 14.2.1 20250207
gcc version gcc (GCC) 14.2.1 20250207
clang version clang version 19.1.7
tcc version tcc version 0.9.28rc 2024-07-31 HEAD@1cee0908 (x86_64 Linux)
tcc git status thirdparty-linux-amd64 0134e9b9
emcc version N/A
glibc version ldd (GNU libc) 2.41

What did you do?
./v -g -o vdbg cmd/v && ./vdbg /tmp/match_err.vv && /tmp/match_err

module main

type Value = int | i64 | u64 | string | []u8

fn main() {
	val := Value(0)
	match val {
		int, i64, u64, []u8 {
			s := sizeof(val)
			println('Value is number or byte array, size=${s}')
		}
		string {
			println('Value is string')
		}
	}
}

What did you see?

================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/match_err.01JMH483Y6AGNJT4YA1Z2M4M1D.tmp.c:5425: error: 'main__int___main__i64___main__u64___main__' undeclared
=================================================================
(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 .

With -show-c-output:

======== Output of the C Compiler (/home/ge/.vlang/thirdparty/tcc/tcc.exe) ========
/tmp/v_1000/match_err.01JMH49E94N1X6Z3X2KDF76W9J.tmp.c:5425: error: 'main__int___main__i64___main__u64___main__' undeclared
===================================================================================
======== Output of the C Compiler (cc) ========
/tmp/v_1000/match_err.01JMH49E94N1X6Z3X2KDF76W9J.tmp.c: In function ‘main__main’:
/tmp/v_1000/match_err.01JMH49E94N1X6Z3X2KDF76W9J.tmp.c:5425:32: error: ‘main__int___main__i64___main__u64___main__’ undeclared (first use in this function)
 5425 |                 u32 s = sizeof(main__int___main__i64___main__u64___main__[]u8);
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/v_1000/match_err.01JMH49E94N1X6Z3X2KDF76W9J.tmp.c:5425:32: note: each undeclared identifier is reported only once for each function it appears in
/tmp/v_1000/match_err.01JMH49E94N1X6Z3X2KDF76W9J.tmp.c:5425:75: error: expected expression before ‘]’ token
 5425 |                 u32 s = sizeof(main__int___main__i64___main__u64___main__[]u8);
      |                                                                           ^
/tmp/v_1000/match_err.01JMH49E94N1X6Z3X2KDF76W9J.tmp.c:5429:75: error: expected expression before ‘]’ token
 5429 |                 u32 s = sizeof(main__int___main__i64___main__u64___main__[]u8);
      |                                                                           ^
/tmp/v_1000/match_err.01JMH49E94N1X6Z3X2KDF76W9J.tmp.c:5433:75: error: expected expression before ‘]’ token
 5433 |                 u32 s = sizeof(main__int___main__i64___main__u64___main__[]u8);
      |                                                                           ^
/tmp/v_1000/match_err.01JMH49E94N1X6Z3X2KDF76W9J.tmp.c:5437:75: error: expected expression before ‘]’ token
 5437 |                 u32 s = sizeof(main__int___main__i64___main__u64___main__[]u8);
      |                                                                           ^
===============================================

What did you expect to see?

No C errors

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.

Copy link

Connected to Huly®: V_0.6-22182

@Delta456 Delta456 added Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: Checker Bugs/feature requests, that are related to the type checker. labels Feb 22, 2025
@Delta456

This comment has been minimized.

@Delta456 Delta456 added Unit: cgen Bugs/feature requests, that are related to the default C generating backend. and removed Unit: Checker Bugs/feature requests, that are related to the type checker. labels Feb 22, 2025
@felipensp felipensp self-assigned this Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants