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: -skip-unused problem #20509

Closed
enghitalo opened this issue Jan 12, 2024 · 0 comments · Fixed by #20527
Closed

cgen: -skip-unused problem #20509

enghitalo opened this issue Jan 12, 2024 · 0 comments · Fixed by #20527
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Generics[T] Bugs/feature requests, that are related to the V generics. 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. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. Unit: markused Bugs/feature requests, that are related to the -skip-unused.

Comments

@enghitalo
Copy link
Contributor

enghitalo commented Jan 12, 2024

Describe the bug

wrog code genered when using -skip-unused

Reproduction Steps

v -skip-unused run bug.v

import time

struct Encoder{}

fn (e &Encoder) encode_value_with_level[T](val T) string {

	str_value := val.format_rfc3339_nano()
	return str_value
}

fn main() {
	e := &Encoder{}

	assert e.encode_value_with_level(time.Time{}) != ""
}

Expected Behavior

assert pass

Current Behavior

==================
/tmp/v_1000/bug.2322882822782176217.tmp.c:6201: warning: implicit declaration of function 'time__Time_format_rfc3339'
/tmp/v_1000/bug.2322882822782176217.tmp.c:6201: error: '{' expected (got ";")
...
==================
(Use `v -cg` to print the entire error message)

builder error: 
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.4 0c4611f

Environment details (OS name and version, etc.)

Ubuntu

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.

@enghitalo enghitalo added the Bug This tag is applied to issues which reports bugs. label Jan 12, 2024
@enghitalo enghitalo mentioned this issue Jan 12, 2024
3 tasks
@spytheman spytheman added Unit: markused Bugs/feature requests, that are related to the -skip-unused. Unit: cgen Bugs/feature requests, that are related to the default C generating backend. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. Generics[T] Bugs/feature requests, that are related to the V generics. Status: Confirmed This bug has been confirmed to be valid by a contributor. labels Jan 12, 2024
@shove70 shove70 self-assigned this Jan 13, 2024
shove70 added a commit to shove70/v that referenced this issue Jan 14, 2024
spytheman pushed a commit that referenced this issue Jan 14, 2024
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. Generics[T] Bugs/feature requests, that are related to the V generics. 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. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. Unit: markused Bugs/feature requests, that are related to the -skip-unused.
Projects
None yet
3 participants