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

Unable to seemingly perform arithmetic operations on polymorphic variables #4276

Open
sudokit opened this issue Sep 20, 2024 · 0 comments
Open

Comments

@sudokit
Copy link

sudokit commented Sep 20, 2024

Context

odin report:

Odin:    dev-2024-09:c1264c2a7
OS:      EndeavourOS, Linux 6.10.10-arch1-1
CPU:     Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
RAM:     23801 MiB
Backend: LLVM 18.1.8

Consider the following code:

foo :: proc(a, b: [$N]$T) -> [N*2]T where N * 2 < 16 {
	// do some stuff here
	fmt.println(N * 2)
	return [N * 2]T{}
}

Everything else works, except the part where we multiply N by two in the return type.

Expected Behavior

To be able to perform arithmetic operations on polymporhic variables, like in the function body or where clauses.

Current Behavior

It throws the following error:

/home/user/projects/tests/main.odin(15:31) Error: 'N' is not an expression but a type, in this context it is ambiguous
        foo :: proc(a, b: [$N]$T) -> [N * 2]T where N * 2 < 16 {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants