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

cgen: fixed array cgen error #20071

Closed
enghitalo opened this issue Dec 2, 2023 · 0 comments · Fixed by #20078
Closed

cgen: fixed array cgen error #20071

enghitalo opened this issue Dec 2, 2023 · 0 comments · Fixed by #20078
Assignees
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@enghitalo
Copy link
Contributor

enghitalo commented Dec 2, 2023

Describe the bug

mut bp := buf4[1..999999] where buf4 is a fixed array, break everything.

Reproduction Steps

module main

fn main() {
	mut buf4 := [1000000]u8{}
	name(mut buf4)
}

fn name[T](mut buf4 T) {
	for idx in 0 .. 1000000 {
		buf4[idx] = idx
	}

	mut bp := buf4[1..999999]

	println(bp.bytestr())
	println(bp.len)
}

Expected Behavior

not cgen error, print a really big string,

make mut bp := buf4[1..999999] act like

	mut bp := []u8{len:999998 }
	for id, variable in buf4 {
		if id == 999999 {
			break
		} else if id >= 1 {
			bp[id] = variable
		}
	}

Current Behavior

==================
/tmp/v_1000/discardable_array_benchmark.9164571563412437262.tmp.c: In function ‘main__name_T_Array_fixed_u8_1000000’:
/tmp/v_1000/discardable_array_benchmark.9164571563412437262.tmp.c:12669:58: error: incompatible type for argument 1 of ‘array_clone_static_to_depth_noscan’
12669 |         Array_u8 bp = array_clone_static_to_depth_noscan(buf4, 1, 999999), 0);
      |                                                          ^~~~
      |                                                          |
      |                                                          u8 (*)[1000000] {aka unsigned char (*)[1000000]}
/tmp/v_1000/discardable_array_benchmark.9164571563412437262.tmp.c:6648:64: note: expected ‘array’ but argument is of type ‘u8 (*)[1000000]’ {aka ‘unsigned char (*)[1000000]’}
 6648 | VV_LOCAL_SYMBOL array array_clone_static_to_depth_noscan(array a, int depth) {
      |                                                          ~~~~~~^
/tmp/v_1000/discardable_array_benchmark.9164571563412437262.tmp.c:12669:23: error: too many arguments to function ‘array_clone_static_to_depth_noscan’
12669 |         Array_u8 bp = array_clone_static_to_depth_noscan(buf4, 1, 999999), 0);
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
==================
(Use `v -cg` to print the entire error message)

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

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.3 a017b53

Environment details (OS name and version, etc.)

Ubuntu

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.

@enghitalo enghitalo added the Bug This tag is applied to issues which reports bugs. label Dec 2, 2023
@felipensp felipensp self-assigned this Dec 3, 2023
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants