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

Incorrect case selected in switch on Maybe(^T) #3947

Closed
diocletiann opened this issue Jul 20, 2024 · 2 comments · Fixed by #4062
Closed

Incorrect case selected in switch on Maybe(^T) #3947

diocletiann opened this issue Jul 20, 2024 · 2 comments · Fixed by #4062
Labels
bug replicated We were able to replicate the bug.

Comments

@diocletiann
Copy link

diocletiann commented Jul 20, 2024

Repro:

package main
import "core:fmt"

foo :: struct {
	x: int,
}

main :: proc() {
	maybe_foo: Maybe(^foo)

	switch v in maybe_foo {
	case ^foo:
		fmt.println("is foo")
	case nil:
		fmt.println("is nil")
	}
}
is foo

Odin: dev-2024-07:7237f9c9f
OS: macOS Sonoma 14.3.1 (build: 23D60, kernel: 23.3.0)
CPU: Apple M1 Max
RAM: 32768 MiB
Backend: LLVM 18.1.8

@Kelimion Kelimion added the replicated We were able to replicate the bug. label Jul 20, 2024
@Kelimion
Copy link
Member

Replicated on latest commit on Windows 10.

@laytan
Copy link
Collaborator

laytan commented Jul 20, 2024

Probably has to do with Maybe(^T) internally not being a union at all, or at least internally doesn't have a tag. So this is probably an edge case not handled in the codegen for this switch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug replicated We were able to replicate the bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants