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

using float/int sumtype cast results in C error #14428

Closed
boonsboos opened this issue May 16, 2022 · 3 comments · Fixed by #18228
Closed

using float/int sumtype cast results in C error #14428

boonsboos opened this issue May 16, 2022 · 3 comments · Fixed by #18228
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor.

Comments

@boonsboos
Copy link
Contributor

boonsboos commented May 16, 2022

writing a bug report due to an issue posted in the discord. message link

What did you do?
a.v

fn cast(a int | f64) f64 {
	return f64(a)
}

println(cast(10))

v run a.v

What did you expect to see?
10. in the console

What did you see instead?

/tmp/v_1000/a.18217470816788589904.tmp.c:11611: error: invalid aggregate type for register load
builder error:
==================

which is the C representation of the function:

f64 main__cast(main___v_anon_sum_type_f64_int a) {
	f64 _t1 = ((f64)(a));
	return _t1;
}

VS Code squiggles this cast, so i suspect this to be a cgen error. using a non-anonymous sumtype results in the same error and C code.

V version: V 0.2.4 bc397bb
OS: Arch Linux 5.16.16-arch-1
Compiler used: tcc

@boonsboos boonsboos added the Bug This tag is applied to issues which reports bugs. label May 16, 2022
@JalonSolov JalonSolov added the Status: Confirmed This bug has been confirmed to be valid by a contributor. label May 16, 2022
@changrui
Copy link
Contributor

Oh, No, It may be a as f64.

@DevrosTheOne
Copy link

DevrosTheOne commented May 17, 2022

[changrui]
f64(a as int) for int parameter

@changrui
Copy link
Contributor

[changrui] f64(a as int) for int parameter

YES, Sir. @DevrosTheOne

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. Status: Confirmed This bug has been confirmed to be valid by a contributor.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants