You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A generic function type with type T errors if used as a parameter for another function that has a different generic letter to T. A version of this with a struct does work.
structFoo[T] {
a T
}
fnf[X](foo Foo[X]) X {
return foo.a
}
fnmain() {
foo:= Foo[int]{10}
println(f[int](foo))
}
however the function type version does not. This leads me to believe even though it is a V error instead of a builder or c error that this is a bug, as I don't see any reason why function types should be excluded from this behavior that structs have.
Reproduction Steps
type Fn[T] =fn () T
fnproblem[X](f Fn[X]) X {
return f[X]()
}
fnfoo() int {
return1
}
fnmain() {
t:= problem[int](foo)
println(t)
}
Expected Behavior
To print 1
Current Behavior
error: generic type name T is not mentioned in fn problem[X]
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.7 9088970.4248fc5
Environment details (OS name and version, etc.)
OS: linux, "Arch Linux"
Processor: 8 cpus, 64bit, little endian, 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
vroot: OK
VMODULES: OK
VTMP: OK
Git version: git version 2.46.0
Git vroot status: weekly.2024.37-64-g4248fc55
.git/config present: true
CC version: cc (GCC) 14.2.1 20240805
thirdparty/tcc status: thirdparty-linux-amd64 a0799a5b
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.
The text was updated successfully, but these errors were encountered:
Trakis196
changed the title
function type generic cannot have another generic letter when used as a parameter
function type generic cannot have a different generic letter when used as a parameter
Sep 25, 2024
Describe the bug
A generic function type with type
T
errors if used as a parameter for another function that has a different generic letter toT
. A version of this with a struct does work.however the function type version does not. This leads me to believe even though it is a V error instead of a builder or c error that this is a bug, as I don't see any reason why function types should be excluded from this behavior that structs have.
Reproduction Steps
Expected Behavior
To print
1
Current Behavior
error: generic type name
T
is not mentioned in fnproblem[X]
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.7 9088970.4248fc5
Environment details (OS name and version, etc.)
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.
The text was updated successfully, but these errors were encountered: