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

Bad generation of Array Alias #22374

Closed
thomas-mangin opened this issue Sep 30, 2024 · 0 comments · Fixed by #22375
Closed

Bad generation of Array Alias #22374

thomas-mangin opened this issue Sep 30, 2024 · 0 comments · Fixed by #22375
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@thomas-mangin
Copy link
Contributor

thomas-mangin commented Sep 30, 2024

Describe the bug

A regression with type alias means they are not generated correctly.

Reproduction Steps

module main

type NLRI = []u8

fn make_loopback() []NLRI {
	raw := [u8(32), 10, 0, 0, 1]
	mut nlris := []NLRI{cap: 1}
	nlris << NLRI(raw[0..5])
	return nlris
}

fn main() {
	r := make_loopback()
	print(r)
	// [[], [], [], [], []]
	// [32, 127, 0, 0, 1]
}

Expected Behavior

It prints the numbers and not the empty list

Current Behavior

My code stopped working, and it makes me sad. It breaks my heart. 🤣

Possible Solution

Alex said I could beg for help and hope for @felipensp to save the day

Additional Information/Context

git disect helped and found this commit:

at 23:25:11 ❯ git bisect bad
33ff7c136b662a553770dfdd9fbac3d331943767 is the first bad commit
commit 33ff7c136b662a553770dfdd9fbac3d331943767 (HEAD)
Author: Felipe Pena <[email protected]>
Date:   Tue Sep 10 11:24:48 2024 -0300

    parser, checker: fix array alias (#22175)

 vlib/v/checker/check_types.v            | 15 +++++++++++++++
 vlib/v/checker/containers.v             | 11 ++++++++++-
 vlib/v/tests/aliases/array_alias_test.v | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 90 insertions(+), 1 deletion(-)
 create mode 100644 vlib/v/tests/aliases/array_alias_test.v

V version

V 0.4.8 aa3ab3f

Environment details (OS name and version, etc.)

V full version: V 0.4.8 aa3ab3f
OS: macos, macOS, 15.0, 24A335
Processor: 10 cpus, 64bit, little endian, Apple M1 Max

getwd: /Users/thomas/Code/github.com/ze-community/ze/main
vexe: /Users/thomas/Unix/local/v/master/v
vexe mtime: 2024-09-30 22:51:15

vroot: OK, value: /Users/thomas/Unix/local/v/master
VMODULES: OK, value: /Users/thomas/Code/github.com/ze-community/ze/main/build/modules
VTMP: OK, value: /Users/thomas/Code/github.com/ze-community/ze/main/build/tmp

Git version: git version 2.46.2
Git vroot status: 0.4.8-8-gaa3ab3ff
.git/config present: true

CC version: Apple clang version 16.0.0 (clang-1600.0.26.3)
thirdparty/tcc status: thirdparty-macos-arm64 713692d4

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.

@thomas-mangin thomas-mangin added the Bug This tag is applied to issues which reports bugs. label Sep 30, 2024
@thomas-mangin thomas-mangin changed the title Bad generation of Array Alias array alias... yeah aliases are tough Bad generation of Array Alias Sep 30, 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant