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
In cases where an embedded member is accessed from within a generic function on the generic type, the second generated function seems to change the path to the embedded member in the first generated function
Reproduction Steps
The following v code produces this issue when compiling:
modulemainstructBase {
i int
}
structBase1 {
Base
}
structBase2 {
Base
}
structStruct1 {
Base1
}
structStruct1O {
Struct1
}
structStruct2 {
Base2
}
structStruct2O {
Struct2
}
fn (b &Base) func[T]() T {
t:= T{
i: b.i
}
if t.i==0 {
}
return t
}
pub fnmain() {
s1:= Struct1{}
s2:= Struct2{}
s1.func[Struct1O]()
s2.func[Struct2O]()
}
Expected Behavior
successful compile
Current Behavior
The following error is produced:
PS C:\Users\jcwea\Documents\git\vtest> v -cg run .
C:/Users/jcwea/AppData/Local/Temp/v_0/vtest.01HPSQPC6R0YY9H4AG342XFR12.tmp.c:501: warning: WINVER redefined
C:/Users/jcwea/AppData/Local/Temp/v_0/vtest.01HPSQPC6R0YY9H4AG342XFR12.tmp.c:6898: warning: implicit declaration of function 'tcc_backtrace'
C:/Users/jcwea/AppData/Local/Temp/v_0/vtest.01HPSQPC6R0YY9H4AG342XFR12.tmp.c:13116: error: field not found: Struct2
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
Looking at the generated C code, it uses the wrong path:
It uses t.Struct2.Base2.Base.i instead of the correct t.Struct1.Base1.Base.i
It seems like the second use of the function poisons the first use of the function
Describe the bug
In cases where an embedded member is accessed from within a generic function on the generic type, the second generated function seems to change the path to the embedded member in the first generated function
Reproduction Steps
The following v code produces this issue when compiling:
Expected Behavior
successful compile
Current Behavior
The following error is produced:
Looking at the generated C code, it uses the wrong path:
It uses
t.Struct2.Base2.Base.i
instead of the correctt.Struct1.Base1.Base.i
It seems like the second use of the function poisons the first use of the function
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.4 1d3147e
Environment details (OS name and version, etc.)
V full version: V 0.4.4 afd74ad.1d3147e
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-16 19:26:43
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.07-30-g1d3147e1
.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.
The text was updated successfully, but these errors were encountered: