Skip to content

C error in array of array push empty array not defined type #23854

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

Open
jorgeluismireles opened this issue Mar 3, 2025 · 2 comments
Open

C error in array of array push empty array not defined type #23854

jorgeluismireles opened this issue Mar 3, 2025 · 2 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@jorgeluismireles
Copy link

jorgeluismireles commented Mar 3, 2025

Describe the bug

We have an array of arrays rows = [][]string{} and push a not defined empty array rows << [ ] and got a C error.

Operation rows << [ ] is not marked as invalid.

A workaround is to push like this: rows << []string{}.

Reproduction Steps

fn one(mut rows [][]string) {
	rows << [ '1a', '1b' ]
}

fn two(empty bool, mut rows [][]string) {
	if empty {
		rows << [ ] // C error
		//rows << []string{} // workaround
	} else {
		rows << [ '2a', '2b' ]
	}
}

fn main() {
	mut rows := [][]string{}
	one(mut rows)
	two(true, mut rows)
	println(rows)
}

Expected Behavior

Print:

[['1a', '1b'], []]

Or inform rows << [] should be changed by row << []string{}

Current Behavior

Running code...
Can't run code. The server returned an error:
/tmp/v_60000/../../../../../../box/code.v:7: error: pointer expected
builder error: 
==================
C error found. It should never happen, when compiling pure V code.

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.9 a59ebea

Environment details (OS name and version, etc.)

https://play.vlang.io/p/734e07e5c5

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.

@jorgeluismireles jorgeluismireles added the Bug This tag is applied to issues which reports bugs. label Mar 3, 2025
Copy link

Connected to Huly®: V_0.6-22258

@felipensp
Copy link
Member

@medvednikov what is the expected behavior in this case?

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