Skip to content

checker: fix type inference when pushing an empty array to a 2D array#25508

Merged
spytheman merged 4 commits into
vlang:masterfrom
StunxFS:fix-empty-array-infix
Oct 22, 2025
Merged

checker: fix type inference when pushing an empty array to a 2D array#25508
spytheman merged 4 commits into
vlang:masterfrom
StunxFS:fix-empty-array-infix

Conversation

@StunxFS

@StunxFS StunxFS commented Oct 15, 2025

Copy link
Copy Markdown
Contributor

Based on PR #24002 (which has been inactive for a while).
Fix #23854.

$ cat x.v
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)
}
$ ./v run x.v
[['1a', '1b'], []]

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-26189

@spytheman spytheman marked this pull request as draft October 16, 2025 12:33
@StunxFS StunxFS marked this pull request as ready for review October 21, 2025 16:57
@StunxFS

StunxFS commented Oct 21, 2025

Copy link
Copy Markdown
Contributor Author

@spytheman I have managed to fix the CI failure that was occurring before.

The current CI failure is not related to this PR, it is related to Vinix.

@JalonSolov

Copy link
Copy Markdown
Collaborator

That's a common failure for vinix, usually caused by a network glitch. I've restarted the job.

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

Thank you for persevering and solving it, @StunxFS 🙇🏻‍♂️.

@spytheman

Copy link
Copy Markdown
Contributor

@TheAhmir thank you too.

@spytheman spytheman merged commit 3dfd06b into vlang:master Oct 22, 2025
83 of 84 checks passed
@StunxFS StunxFS deleted the fix-empty-array-infix branch October 22, 2025 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants