Skip to content

Short program with interface smartcasting does not compile with -skip-unused #24579

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

Closed
gechandesu opened this issue May 25, 2025 · 1 comment · Fixed by #24583
Closed

Short program with interface smartcasting does not compile with -skip-unused #24579

gechandesu opened this issue May 25, 2025 · 1 comment · Fixed by #24583
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Status: Has Workaround This issue has workaround. Unit: markused Bugs/feature requests, that are related to the -skip-unused.

Comments

@gechandesu
Copy link
Contributor

gechandesu commented May 25, 2025

V version: V 0.4.10 22c327f, press to see full `v doctor` output
V full version V 0.4.10 89d1aac.22c327f
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 2.55GB/15.35GB
V executable /home/ge/.vlang/v
V last modified time 2025-05-24 11:12:38
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: /tmp
env VFLAGS "-W"
Git version git version 2.49.0
V git status weekly.2025.16-203-g22c327fe
.git/config present true
cc version cc (GCC) 15.1.1 20250425
gcc version gcc (GCC) 15.1.1 20250425
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 myerr.v && myerr

module main

pub struct MyError implements IError {
pub:
	msg    string
	code   int
	domain int
	level  int
}

pub fn (e MyError) str() string {
	return '${e.msg} ${e.code}:${e.domain}:${e.level}'
}

pub fn (e MyError) msg() string {
	return e.msg
}

pub fn (e MyError) code() int {
	return e.code
}

fn MyError.new(msg string, code int, domain int, level int) MyError {
	return MyError{
		msg:    msg
		code:   code
		domain: domain
		level:  level
	}
}

fn foo() ! {
	return MyError.new('xxx', 1, 1, 1)
}

fn main() {
	foo() or {
		if err is MyError {
			eprintln(err)
		}
	}
}

What did you see?

================== C compilation error (from tcc): ==============
cc: /tmp/v_1000/myerr.01JW4R108Q4DGSDVXSEWWGEVDE.tmp.c:5685: warning: implicit declaration of function 'isnil'
cc: /home/ge/.vlang/thirdparty/tcc/lib/libgc.a: error: 'GC_noop1_ptr' defined twice
cc: tcc: error: undefined symbol 'isnil'
=================================================================
(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?

Program should print xxx 1:1: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.

Copy link

Connected to Huly®: V_0.6-22944

@felipensp felipensp added Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Status: Has Workaround This issue has workaround. Unit: markused Bugs/feature requests, that are related to the -skip-unused. labels May 26, 2025
@felipensp felipensp self-assigned this May 26, 2025
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. Status: Confirmed This bug has been confirmed to be valid by a contributor. Status: Has Workaround This issue has workaround. Unit: markused Bugs/feature requests, that are related to the -skip-unused.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants