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

c error when wrapping a function in an optional function type #22670

Closed
heyimtcn opened this issue Oct 27, 2024 · 0 comments · Fixed by #22676
Closed

c error when wrapping a function in an optional function type #22670

heyimtcn opened this issue Oct 27, 2024 · 0 comments · Fixed by #22676
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Option Type Bugs/feature requests, that are related to `?Type`. 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

@heyimtcn
Copy link
Contributor

heyimtcn commented Oct 27, 2024

Describe the bug

?Foo(none) with Foo being a function type def causes a build error

Reproduction Steps

v -cg -show-c-output -cc gcc .

type Foo = fn (bar string)

fn main() {
    mut func := ?Foo(none)
    dump(func)
}

Expected Behavior

a compiled program

Current Behavior

======== Output of the C Compiler (gcc) ========
C:\Users\nicof\AppData\Local\Temp\v_0\foo.01JB7DV7N82CMDR7ZC0RYB36A4.tmp.c: In function '_v_dump_expr__option_main__Foo':
C:\Users\nicof\AppData\Local\Temp\v_0\foo.01JB7DV7N82CMDR7ZC0RYB36A4.tmp.c:2305:24: error: too few arguments to function '_option_anon_fn_string_str'
 2305 |         string value = _option_anon_fn_string_str();
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\nicof\AppData\Local\Temp\v_0\foo.01JB7DV7N82CMDR7ZC0RYB36A4.tmp.c:2291:8: note: declared here
 2291 | string _option_anon_fn_string_str(_option_anon_fn_string it) { return indent__option_anon_fn_string_str(it, 0); }
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\nicof\AppData\Local\Temp\v_0\foo.01JB7DV7N82CMDR7ZC0RYB36A4.tmp.c: In function 'main__main':
C:\Users\nicof\AppData\Local\Temp\v_0\foo.01JB7DV7N82CMDR7ZC0RYB36A4.tmp.c:13645:75: error: incompatible type for argument 4 of '_v_dump_expr__option_main__Foo'
13645 |          _v_dump_expr__option_main__Foo(_SLIT("foo.v"), 5, _SLIT("func"), func);
      |                                                                           ^~~~
      |                                                                           |
      |                                                                           _option_anon_fn_string
C:\Users\nicof\AppData\Local\Temp\v_0\foo.01JB7DV7N82CMDR7ZC0RYB36A4.tmp.c:2303:128: note: expected 'DumpFNType__option_main__Foo' {aka 'void (*)(string)'} but argument is of type '_option_anon_fn_string'
 2303 | DumpFNType__option_main__Foo _v_dump_expr__option_main__Foo(string fpath, int line, string sexpr, DumpFNType__option_main__Foo dump_arg) {
      |                                                                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
================================================

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.8 c8ddf21

Environment details (OS name and version, etc.)

V full version: V 0.4.8 c8ddf21
OS: windows, Microsoft Windows 11 Pro v22631 64-bit
Processor: 16 cpus, 64bit, little endian, 

getwd: C:\Users\nicof\Desktop\Projects\V\studytui
vexe: C:\Users\nicof\Desktop\v\v.exe
vexe mtime: 2024-10-27 16:43:14

vroot: OK, value: C:\Users\nicof\Desktop\v
VMODULES: OK, value: C:\Users\nicof\.vmodules
VTMP: OK, value: C:\Users\nicof\AppData\Local\Temp\v_0

Git version: git version 2.45.2.windows.1
Git vroot status: weekly.2024.43-47-gc8ddf219
.git/config present: true

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

thirdparty/tcc: N/A

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.

Huly®: V_0.6-21119

@heyimtcn heyimtcn added the Bug This tag is applied to issues which reports bugs. label Oct 27, 2024
@felipensp felipensp added Status: Confirmed This bug has been confirmed to be valid by a contributor. Option Type Bugs/feature requests, that are related to `?Type`. labels Oct 27, 2024
@felipensp felipensp self-assigned this Oct 27, 2024
@felipensp felipensp added the Unit: cgen Bugs/feature requests, that are related to the default C generating backend. label Oct 27, 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. Option Type Bugs/feature requests, that are related to `?Type`. 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.

2 participants