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

Simple V file with arguments() function not compiling #23436

Closed
tricarte opened this issue Jan 11, 2025 · 3 comments · Fixed by #23437
Closed

Simple V file with arguments() function not compiling #23436

tricarte opened this issue Jan 11, 2025 · 3 comments · Fixed by #23437
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: markused Bugs/feature requests, that are related to the -skip-unused.

Comments

@tricarte
Copy link

tricarte commented Jan 11, 2025

Describe the bug

Just wanted to test the arguments()' method in the builtin` module. But the compiler gives error.

Reproduction Steps

Create a new V project called 'arguments':

v init arguments

Use below as the content of main.v:

module main

fn main() {
	args := arguments()
	println(args)
}

Try to compile the program:

v -prod . # or 'v .'

Expected Behavior

Program should compile without error.

Current Behavior

This is the output of v -show-c-output -prod .

======== Output of the C Compiler (cc) ========
/tmp/v_1000/arguments.01JHAVW7NT6P8BN64Y1QQ58RHG.tmp.c: In function ‘strings__new_builder’:
/tmp/v_1000/arguments.01JHAVW7NT6P8BN64Y1QQ58RHG.tmp.c:1314:34: warning: implicit declaration of function ‘__new_array_with_default_noscan’ [-Wimplicit-function-declaration]
 1314 |         strings__Builder res = ((__new_array_with_default_noscan(0, initial_size, sizeof(u8), 0)));
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/v_1000/arguments.01JHAVW7NT6P8BN64Y1QQ58RHG.tmp.c:1314:32: error: invalid initializer
 1314 |         strings__Builder res = ((__new_array_with_default_noscan(0, initial_size, sizeof(u8), 0)));
      |                                ^
/tmp/v_1000/arguments.01JHAVW7NT6P8BN64Y1QQ58RHG.tmp.c: In function ‘strings__Builder_write_u8’:
/tmp/v_1000/arguments.01JHAVW7NT6P8BN64Y1QQ58RHG.tmp.c:1319:9: warning: implicit declaration of function ‘array_push_noscan’; did you mean ‘array_push_many’? [-Wimplicit-function-declaration]
 1319 |         array_push_noscan((array*)b, _MOV((u8[]){ data }));
      |         ^~~~~~~~~~~~~~~~~
      |         array_push_many
/tmp/v_1000/arguments.01JHAVW7NT6P8BN64Y1QQ58RHG.tmp.c: In function ‘arguments’:
/tmp/v_1000/arguments.01JHAVW7NT6P8BN64Y1QQ58RHG.tmp.c:1966:28: warning: implicit declaration of function ‘__new_array_with_default’ [-Wimplicit-function-declaration]
 1966 |         Array_string res = __new_array_with_default(0, g_main_argc, sizeof(string), 0);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~
/tmp/v_1000/arguments.01JHAVW7NT6P8BN64Y1QQ58RHG.tmp.c:1966:28: error: invalid initializer
/tmp/v_1000/arguments.01JHAVW7NT6P8BN64Y1QQ58RHG.tmp.c:1973:25: warning: implicit declaration of function ‘array_push’ [-Wimplicit-function-declaration]
 1973 |                         array_push((array*)&res, _MOV((string[]){ tos_clone(argv[i]) }));
      |                         ^~~~~~~~~~
===============================================

Possible Solution

No response

Additional Information/Context

No response

V version

0.4.9 bed28d1

Environment details (OS name and version, etc.)

|V full version      |V 0.4.9 e61475e.bed28d1
|:-------------------|:-------------------
|OS                  |linux, Ubuntu 24.04.1 LTS
|Processor           |4 cpus, 64bit, little endian, Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz
|Memory              |0.23GB/3.7GB
|                    |
|V executable        |/home/user/repos/v/v
|V last modified time|2025-01-11 13:54:08
|                    |
|V home dir          |OK, value: /home/user/repos/v
|VMODULES            |OK, value: /home/user/.vmodules
|VTMP                |OK, value: /tmp/v_1000
|Current working dir |OK, value: /home/user/repos/v
|                    |
|Git version         |git version 2.43.0
|V git status        |weekly.2025.1-29-gbed28d1e
|.git/config present |true
|                    |
|cc version          |cc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
|gcc version         |gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
|clang version       |Ubuntu clang version 18.1.3 (1ubuntu1)
|tcc version         |tcc version 0.9.28rc 2024-07-31 HEAD@1cee0908 (x86_64 Linux)
|tcc git status      |thirdparty-linux-amd64 0134e9b9
|emcc version        |N/A
|glibc version       |ldd (Ubuntu GLIBC 2.39-0ubuntu8.3) 2.39

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.

@tricarte tricarte added the Bug This tag is applied to issues which reports bugs. label Jan 11, 2025
@felipensp felipensp self-assigned this Jan 11, 2025
@felipensp felipensp added the Unit: markused Bugs/feature requests, that are related to the -skip-unused. label Jan 11, 2025
@JalonSolov
Copy link
Contributor

Same program, in a differently named directory, with the code in a file named x.v (to make sure that wasn't part of the problem), and run with v -g run x.v gives:

/tmp/v_1000/../../../../../../home/jalon/git/v/vlib/strings/builder.c.v:14: warning: implicit declaration of function '__new_array_with_default_noscan'
/tmp/v_1000/../../../../../../home/jalon/git/v/vlib/strings/builder.c.v:14: error: '{' expected (got ";")
builder error: 
==================
...

@felipensp
Copy link
Member

As a temporary workaround use -no-skip-unused param to v.

@JalonSolov JalonSolov added the Status: Confirmed This bug has been confirmed to be valid by a contributor. label Jan 11, 2025
@JalonSolov
Copy link
Contributor

Confirmed - that makes it work as expected:

$ v -g -no-skip-unused run x.v
['/home/jalon/x']
$

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. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: markused Bugs/feature requests, that are related to the -skip-unused.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants