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

typed fns do not match correctly in compile time code #20928

Closed
jcweaver997 opened this issue Feb 29, 2024 · 0 comments · Fixed by #22549
Closed

typed fns do not match correctly in compile time code #20928

jcweaver997 opened this issue Feb 29, 2024 · 0 comments · Fixed by #22549
Labels
Bug This tag is applied to issues which reports bugs. Comptime Features processed during compile time, like $if, $for, $env etc Feature Request This issue is made to request a feature. Unit: Type System Bugs/feature requests, that are related to the V types system.

Comments

@jcweaver997
Copy link

jcweaver997 commented Feb 29, 2024

Describe the bug

When checking if a method matches a certain signature in compile time code, it does not return true even when it matches

Reproduction Steps

module main

struct Struct1 {
	num f64
}

pub type DoThingFunc = fn(f32) bool

fn (mut s Struct1) do_thing(a f32) bool {
	return false
}

fn register[T](){
	$for method in T.methods {
		$if method is DoThingFunc {
			println("method ${method.name} is do thing")
		}$else{
			println("method ${method.name} is not do thing")
		}
	}
}

pub fn main() {
	register[Struct1]()
}

Expected Behavior

It should printmethod do_thing is do thing

Current Behavior

It prints method do_thing is not do thing

Possible Solution

No response

Additional Information/Context

I've also tried $if method.typ is DoThingFunc and it doesn't match either

V version

V 0.4.4 70c277d

Environment details (OS name and version, etc.)

V full version: V 0.4.4 1733dab.70c277d
OS: windows, Microsoft Windows 11 Pro v26058 64-bit
Processor: 24 cpus, 64bit, little endian,

getwd: C:\Users\jcwea\Documents\git\vtest
vexe: C:\Users\jcwea\Documents\git\v\v.exe
vexe mtime: 2024-02-29 15:47:47

vroot: OK, value: C:\Users\jcwea\Documents\git\v
VMODULES: OK, value: C:\Users\jcwea.vmodules
VTMP: OK, value: C:\Users\jcwea\AppData\Local\Temp\v_0

Git version: git version 2.40.0.windows.1
Git vroot status: weekly.2024.09-6-g70c277d4
.git/config present: true

CC version: Error: 'cc' is not recognized as an internal or external command,
operable program or batch file.

thirdparty/tcc status: thirdparty-windows-amd64 b99a453d

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.

@jcweaver997 jcweaver997 added the Bug This tag is applied to issues which reports bugs. label Feb 29, 2024
@felipensp felipensp added Unit: Type System Bugs/feature requests, that are related to the V types system. Comptime Features processed during compile time, like $if, $for, $env etc labels Mar 5, 2024
@felipensp felipensp added the Feature Request This issue is made to request a feature. label Sep 29, 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. Comptime Features processed during compile time, like $if, $for, $env etc Feature Request This issue is made to request a feature. Unit: Type System Bugs/feature requests, that are related to the V types system.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants