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

LLVM backend error when equality comparison with using type #4734

Open
amjoshuamichael opened this issue Jan 21, 2025 · 0 comments
Open

LLVM backend error when equality comparison with using type #4734

amjoshuamichael opened this issue Jan 21, 2025 · 0 comments

Comments

@amjoshuamichael
Copy link

When comparing a variable of type A with a variable of type B where B is using type A, compiler throws an error at the LLVM backend.

Context

Odin:    dev-2025-01:2aae4cfd4
OS:      macOS Unknown
CPU:     Apple M2 Max
RAM:     32768 MiB
Backend: LLVM 19.1.6

Expected Behavior

 Error: Cannot compare expression, mismatched types '^Inner_Data' and 'Data_Container' 
	if data_ptr == container { 
	   ^~~~~~~~~~~~~~~~~~~~^ 

Current Behavior

lb_emit_conv: src -> dst
Not Identical ^Inner_Data != Data_Container
Not Identical ^Inner_Data != struct {inner_data: ^Inner_Data, x: u32}
Not Identical 113f1a460 != 102efc540
Not Identical 113f1a460 != 102efc5e0
src/llvm_backend_expr.cpp(2494): Panic: Invalid type conversion: '^Inner_Data' to 'Data_Container' for procedure 'main'
zsh: trace trap  odin build . -debug

Failure Information (for bugs)

Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.

Steps to Reproduce

Here is a minimal reproducible example:

package odinbug

import "core:fmt"

Inner_Data :: struct { }

Data_Container :: struct {
    using inner_data: ^Inner_Data,
    x: u32,
}

main :: proc() {
    container := Data_Container {}

    data_ptr: ^Inner_Data

    if data_ptr == container {
        fmt.printf("here!")
    }
}

Here's an online playground example.

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

1 participant