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

c-style for loop with type alias provokes build error #21707

Closed
pd-giz-dave opened this issue Jun 20, 2024 · 0 comments · Fixed by #21708
Closed

c-style for loop with type alias provokes build error #21707

pd-giz-dave opened this issue Jun 20, 2024 · 0 comments · Fixed by #21708
Assignees
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@pd-giz-dave
Copy link

pd-giz-dave commented Jun 20, 2024

Describe the bug

A c-style for loop with a type alias variable results in a build error

Reproduction Steps

Attempt to compile this:

module main
type Float = f32
// for loop with a type alias var of Float get build error
// replacing Float() with f32() works
fn main() {
	min_value := Float(1)
	max_value := Float(10)
	step := Float(1)
	for n := min_value; n <= max_value; n += step {
		print(',${n}')
	}
}

Expected Behavior

I expect to it to compile

Current Behavior

Get a build error:

/home/dave/v/v /home/dave/precious/fellsafe/v/compiler_bugs -color -o /home/dave/precious/fellsafe/v/bin/main
builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .
==================
/tmp/v_1000/main.01J0V23EWTE568C2JCCP4PK2CR.tmp.c:13147: error: ')' expected (got ";")
...
==================
(Use `v -cg` to print the entire error message)

Possible Solution

Use a DIY loop

Additional Information/Context

Replacing the type alias with a native type works.

V version

V 0.4.6 537fa1b

Environment details (OS name and version, etc.)

dave@dave-mini-pc~/.../fellsafe/v >>> v doctor
V full version: V 0.4.6 294f7e4.537fa1b
OS: linux, "EndeavourOS Linux"
Processor: 16 cpus, 64bit, little endian, AMD Ryzen 7 5800H with Radeon Graphics

getwd: /home/dave/precious/fellsafe/v
vexe: /home/dave/v/v
vexe mtime: 2024-06-20 14:51:25

vroot: OK, value: /home/dave/v
VMODULES: OK, value: /home/dave/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.45.2
Git vroot status: weekly.2024.23-43-g537fa1bb
.git/config present: true

CC version: cc (GCC) 14.1.1 20240522
thirdparty/tcc status: thirdparty-linux-amd64 40e5cbb5
dave@dave-mini-pc~/.../fellsafe/v >>>       

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.

@pd-giz-dave pd-giz-dave added the Bug This tag is applied to issues which reports bugs. label Jun 20, 2024
@Delta456 Delta456 self-assigned this Jun 20, 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.

2 participants