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

Cannot determine polymorphic type when using using #3450

Open
viyic opened this issue Apr 19, 2024 · 2 comments
Open

Cannot determine polymorphic type when using using #3450

viyic opened this issue Apr 19, 2024 · 2 comments

Comments

@viyic
Copy link

viyic commented Apr 19, 2024

Context

  • Operating System & Odin Version: Windows 11 & Odin Version dev-2024-04:20223345a
  • Please paste odin report output:
        Odin:    dev-2024-04:20223345a
        OS:      Windows 11 Unknown Edition (00000064) (version: 22H2), build 22621.3447
        CPU:     AMD Ryzen 3 7320U with Radeon Graphics
        RAM:     7412 MiB
        Backend: LLVM 17.0.1

Expected Behavior

You should be able to pass a struct with a using polymorphic member to a function that can take it.

Current Behavior

Odin can't determine the type.
main.odin(23:8) Error: Cannot determine polymorphic type from parameter: '^Wrapper' to '^Array($T)'

Steps to Reproduce

package main

import "core:fmt"

Position :: struct {
	x, y: f32,
}

Array :: struct($T: typeid) {
	array: [32]T,
}

Wrapper :: struct {
	using positions: Array(Position),
}

print :: proc(array: ^Array($T)) {
	fmt.println(array.array)
}

main :: proc() {
	wrapper: Wrapper
	print(&wrapper)
	// print(&wrapper.positions)
}
@gingerBill
Copy link
Member

This is something I am not sure if I want to allow or not. I understand why people want it, but at the same time it enables a bunch of "horrors" too.

@viyic
Copy link
Author

viyic commented Apr 23, 2024

For me, it's just for ergonomics, but yeah, I guess it could be abused pretty hard. If it's not allowed, my suggestion is to clarify it in the error message.

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

No branches or pull requests

2 participants