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

V compiler fails to pass struct method to C #21980

Closed
veranovus opened this issue Aug 1, 2024 · 0 comments · Fixed by #22006
Closed

V compiler fails to pass struct method to C #21980

veranovus opened this issue Aug 1, 2024 · 0 comments · Fixed by #22006
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.

Comments

@veranovus
Copy link

veranovus commented Aug 1, 2024

Describe the bug

V compiler fails to pass struct method to C.

Reproduction Steps

  1. Import a function from C
  2. Create an interface
  3. Create a struct that implements said interface
  4. Create a function that takes generic type but no arguments
  5. Use that function to create she Struct and pass its method to a function that is imported from C

Small sample that reproduces the bug: https://github.com/veranovus/v-bug-report

Expected Behavior

I was expecting struct's method to be passed to the C function.

Current Behavior

================== C compilation error (from cc): ==============
cc: /tmp/v_501/bug_report.01J47TN359BPQMPFN4DM6KCKSM.tmp.c:12864:12: error: use of undeclared identifier 'main__Module_import_'; did you mean 'main__TestModule_import_'?
cc:         test_func(main__Module_import_, ((char*)(_SLIT("TestModule").str)));
cc:                   ^~~~~~~~~~~~~~~~~~~~
cc:                   main__TestModule_import_
cc: /tmp/v_501/bug_report.01J47TN359BPQMPFN4DM6KCKSM.tmp.c:12854:22: note: 'main__TestModule_import_' declared here
cc: VV_LOCAL_SYMBOL void main__TestModule_import_(main__TestModule mod) {
cc:                      ^
cc: 1 error generated.
================================================================
(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 .

Possible Solution

No idea, fix compiler ^^

Additional Information/Context

No response

V version

V 0.4.7 a4b8768

Environment details (OS name and version, etc.)

V full version: V 0.4.7 d43f0e4.a4b8768
OS: macos, macOS, 14.3.1, 23D60
Processor: 8 cpus, 64bit, little endian, Apple M1

getwd: /Users/vera/Documents/V/bug_report
vexe: /Users/vera/Documents/V/v/v
vexe mtime: 2024-08-01 20:39:11

vroot: OK, value: /Users/vera/Documents/V/v
VMODULES: OK, value: /Users/vera/.vmodules
VTMP: OK, value: /tmp/v_501

Git version: git version 2.39.3 (Apple Git-145)
Git vroot status: weekly.2024.31-25-ga4b87681
.git/config present: true

CC version: Apple clang version 15.0.0 (clang-1500.1.0.2.5)
thirdparty/tcc status: thirdparty-macos-arm64 713692d4

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.

@veranovus veranovus added the Bug This tag is applied to issues which reports bugs. label Aug 1, 2024
@spytheman spytheman added Unit: cgen Bugs/feature requests, that are related to the default C generating backend. 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 Aug 1, 2024
@felipensp felipensp self-assigned this Aug 7, 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants